/* findfirst and findnext example */ #include #include /* For Win32, the format of the structure ffblk is as follows: struct ffblk { long ff_reserved; long ff_fsize; /* file size */ unsigned long ff_attrib; /* attribute found */ unsigned short ff_ftime; /* file time */ unsigned short ff_fdate; /* file date */ char ff_name[256]; /* found file name */ }; findfirst begins a search of a disk directory for files specified by attributes or wildcards. findnext is used to fetch subsequent files that match the pathname given n findfirst. ffblk is the same block filled in by the findfirst call. This block contains necessary information for continuing the search. One file name for each call to findnext will be returned until no more files are found in the directory matching the pathname. */ int main(void) { struct ffblk ffblk; int done; printf("Directory listing of *.*\n"); done = findfirst("*.*",&ffblk,0); while (!done) { printf(" %s %d \n", ffblk.ff_name, ffblk.ff_fsize); done = findnext(&ffblk); } return 0; }