need help in getting file directory
what is the problem of my program? why not work?
argv[2] is ../bin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <windows.h>
#include <stdio.h>
#include <iostream>
#define SIZE 128
using namespace std;
int GetFileLists(const char *dir, char files[][SIZE]){
int checker = 0;
int index = 0;
WIN32_FIND_DATA findFileData;
HANDLE hFind = FindFirstFile((LPCSTR)dir, &findFileData);
do {
strcpy(files[index], findFileData.cFileName);
checker = FindNextFile(hFind, &findFileData);
index++;
} while (checker);
return index;
}
int main(int argc, char** argv)//main part
{
string path=argv[2];
if (argc<4) // no enter txt file by themselves in argv
{
char files[SIZE][SIZE];
string file_name=path+string("*.*");
int size = GetFileLists(file_name.c_str(), files);
for (int i=0; i< size; i++)
{
cout << files[i] << endl;
}
}
}
|
Last edited on
You're passing ../bin*.*
to FindFirstFile rather than ../bin/*.*
Last edited on
but why my program print result as:
.
..
filename1
filename2
how to solve this program?? plz help
You could start by stating what the program is supposed to do and what you think is wrong and where you need help.
Topic archived. No new replies allowed.