From: Sune DOT S DOT Falck AT telia DOT se (Sune Falck) Subject: Re: directory listings 17 Mar 1998 21:30:37 -0800 Message-ID: <199803161838.TAA05034.cygnus.gnu-win32@farsta.trab.se> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit To: "Scott Mueller" , ---------- > From: Scott Mueller > To: gnu-win32 AT cygnus DOT com > Subject: directory listings > Date: den 14 mars 1998 01:00 > > I can't believe how incredibly frustrating it has been to simply display > a list of files in the current directory with a c program. I wrote code The following example compiles in MSVC 4.2 and in gcc 2.8.1 mingw32 without any problems. compile with "cl find.c" in MSVC or "cc -o find.exe find.c" with gcc. D:\tmp>cc -o find.exe find.c D:\tmp>find File name : . File name : .. File name : adder.c File name : adder.o File name : adder.obj File name : atest-g.exe File name : atest.adb File name : atest.ali File name : atest.o File name : btest.adb File name : btest.ali find.c ------ #include #include #define WIN32_LEAN_AND_MEAN #include int main (int argc, char ** argv) { HANDLE Find_Handle; WIN32_FIND_DATA Find_Info; Find_Handle = FindFirstFile ("*.*", &Find_Info); if (Find_Handle == INVALID_HANDLE_VALUE) { fprintf (stderr, "No files or other error !\n"); return EXIT_FAILURE; } else { do { fprintf (stdout, "File name : %s\n", Find_Info.cFileName); } while (FindNextFile (Find_Handle, &Find_Info)); FindClose (Find_Handle); } return EXIT_SUCCESS; } - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".