Hi,
I am working on a little example that Bascily scans a Path and grabs all the file names, then store them into an array. Anyway most of the code is working find all expect the last part were I need to display the output.
I left a copy of all my code below and commented. it
VB Code:
#include <iostream> #include <fstream> #include <windows.h> using namespace std; int main(int agvc) { WIN32_FIND_DATA fd; HANDLE FindFile; int cnt=0; char findPath[80]; char **Filename; strcpy(findPath,"C:\\*.*"); // path to scan FindFile = FindFirstFile(findPath, &fd); // Get first file handle if(FindFile == INVALID_HANDLE_VALUE) { // oops error cout << "INVALID_HANDLE_VALUE\n"; exit(1); } do{ if((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) continue; // is it possiable I am doing something wrong here. Filename = (char**) malloc(cnt); // Reszie arry to hold the filenames Filename[cnt] = fd.cFileName; // store filename cnt++; }while(FindNextFile(FindFile,&fd)); FindClose(FindFile); // close file handle std::cout << Filename[0] << endl; // Why is this giveing an error return 0; }
If anyone can help I whould be very greatfull




Reply With Quote