Click to See Complete Forum and Search --> : FindFirst and Next help
Chris_SE
Dec 8th, 2000, 01:07 PM
If I try this:
[code]
#include <iostream.h>
#include <windows.h>
void main()
{
WIN32_FIND_DATA data;
FindFirstFile("c:/*.cpp",&data);
cout<<&data;
}
[code]
I get a number that looks like a memory address. How can I extract the filename??
Vlatko
Dec 8th, 2000, 01:13 PM
No no . You can't print data. Data is a WIN32_FIND_DATA structure now. To get the filename use:
cout<<data.cFileName;
Chris_SE
Dec 8th, 2000, 07:45 PM
When i tried that b4 it printed a wierd symbol
Vlatko
Dec 9th, 2000, 04:34 AM
That is because maybe there are no cpp files in that dir. I tried this code and it works. If there are cpp files it prints the file name of the first one else it prints nothing.
WIN32_FIND_DATA data;
if(FindFirstFile("c:/*.cpp",&data) != INVALID_HANDLE_VALUE)
{
cout<<data.cFileName;
}
Chris_SE
Dec 9th, 2000, 11:24 AM
Ill try that :)
Chris_SE
Dec 10th, 2000, 03:43 PM
My syntax is like that but findnext in a loop will only return the first file. Any ideas?
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.