The malfunctioning code snippet:
I don't have a clue whats wrong with it!Code:ifstream uFile; struct stat results; char filePath[fileName.size()]; chstr(fileName,*filePath); uFile.open(filePath, ios::in | ios::binary); if ( !uFile.is_open() ) { return false; } stat(filePath, &results); if (results.st_size <= 0) { return false; } archFiles[fileAmt] = malloc(results.st_size+1); uFile.read(((char*)archFiles[fileAmt]),results.st_size);
Anyway, more in depth the last two lines are the problem.
Everytime it gets to uFile.read the program crashes.
A note:
archfiles is defined as such:
I'm certain the problem lies in archFiles[fileAmt] but I haven't a clue whats wrong with it. Even an attempt to print out the value of the pointer (after the malloc ofc) results in a crash at the print statement!Code:void * archFiles[];
Edit: More info, I'm using windows and my compiler is g++




Reply With Quote