|
-
Dec 8th, 2000, 02:07 PM
#1
Thread Starter
Addicted Member
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??
-
Dec 8th, 2000, 02:13 PM
#2
Frenzied Member
No no . You can't print data. Data is a WIN32_FIND_DATA structure now. To get the filename use:
Code:
cout<<data.cFileName;
-
Dec 8th, 2000, 08:45 PM
#3
Thread Starter
Addicted Member
hmm
When i tried that b4 it printed a wierd symbol
-
Dec 9th, 2000, 05:34 AM
#4
Frenzied Member
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.
Code:
WIN32_FIND_DATA data;
if(FindFirstFile("c:/*.cpp",&data) != INVALID_HANDLE_VALUE)
{
cout<<data.cFileName;
}
-
Dec 9th, 2000, 12:24 PM
#5
Thread Starter
Addicted Member
thanks
Ill try that
-
Dec 10th, 2000, 04:43 PM
#6
Thread Starter
Addicted Member
My syntax
My syntax is like that but findnext in a loop will only return the first file. Any ideas?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|