|
From: Nurhidayat <dh...@ma...> - 2001-07-30 05:18:52
|
At 06:54 PM 7/28/01 +0000, you wrote:
>hello everyone. i was just wondering how i could get my c++ program to view
>what file names there are in its directory.
>i really need the code if anyone could help.
>thanyou.
You need _findfirst() and _findnext() functions those included by io.h
library. A simple code example given here:
#include <io.h>
#include <iostream.h>
#include <stdlib.h>
int main()
{
_finddata_t myfile;
int myhandle;
if ((myhandle = _findfirst("*.*", &myfile)) >= 0) {
do {
cout << myfile.name << endl;
} while (_findnext(myhandle, &myfile) >= 0);
_findclose(myhandle);
}
else {
cout << "File not found" << endl;
}
system("pause");
return 0;
}
___Nurhidayat___
|