|
From: Anand, V. R <vai...@bo...> - 2004-05-19 15:03:18
|
I get errors as well. The program finds the first two files (which are
always "." and ".."), then dies with a segmentation violation. Until a
solution can be found, perhaps you should use the Win32 API functions
directly instead, as below:
------------------------------------------------------------------------
-------
#include <stdio.h>
#include <windows.h>
int main()
{
HANDLE handle=3D0;
WIN32_FIND_DATA s;
handle =3D FindFirstFile( "*.*", &s );
printf( "handle =3D %d name=3D%s size=3D<%d %d>\n", handle,s.cFileName,
s.nFileSizeHigh,s.nFileSizeLow );
while(FindNextFile(handle, &s)){
printf("name=3D%s size=3D<%d %d>\n",
s.cFileName,s.nFileSizeHigh,s.nFileSizeLow);
}
FindClose(handle);
system("pause");
}
------------------------------------------------------------------------
--------
This seems to work.
Regards,
Anand
-----Original Message-----
From: sebastien kramm [mailto:seb...@wa...]=20
Sent: Wednesday, May 19, 2004 12:51 AM
To: min...@li...
Subject: [Mingw-users] problem with reading dirs (_findfirst())
Hi,
This is my first post here, and I hope this isn't off-topic.
I'm developing under DevCpp 4.9.8, in straight C, and have a problem
reading directories. I tryed to use the _findfirst() function provided
in the Mingw header "io.h" (Revision: 1.6, Date: 2002/11/12).
I'm just trying to read the files in a directory, but the simpliest code
below gives incoherent results. Do I miss something ? Should I use
another function?
-------------------------------------
#include <stdio.h>
#include <io.h>
int main()
{
int handle;
struct _finddata_t s;
handle =3D _findfirst( "*.*", &s );
printf( "handle =3D %d\n", handle );
handle =3D _findnext( handle, &s );
printf( "handle =3D %d\n", handle );
system("pause");
}
-------------------------------------
Sebastien Kramm
-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband Sign-up now
for SourceForge Broadband and get the fastest 6.0/768 connection for
only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=3D2562&alloc_id=3D6184&op=3Dclick
_______________________________________________
MinGW-users mailing list
Min...@li...
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
|