Want to get the path of the 3 picture
E: \ picture \ 1. JPG
E: \ picture \ 2. JPG
E: \ picture \ 3. JPG
Visual studio2017 debugx64
Online to find an error, just contact c gagarin soon, I won't change, and a can directly use the code, thank you
CodePudding user response:
It seems that your file path is Windows, development IDE is visual studio, I'll get a Windows version, only supplies the reference:# include & lt; IO. H>
#include
#include
# define MAX_LEN 4096
Int main (void)
{
Char root []="E: \ \ picture";
Struct _finddata_t file;
Intptr_t hFile;
Char buf [MAX_LEN];
If (_chdir (root))
{
Printf (" failure: open the folder % s/n ", the root).
return 1;
}
HFile=_findfirst (" *.jpg ", & amp; The file);
While (_findnext (hFile, & amp; The file)==0)
{
Sprintf_s (buf MAX_LEN, "% s \ \ % s", root, the file. The name).
Printf (" % s \ n ", buf);
}
return 0;
}