I'm getting a strange file handle from fopen
; the pointer itself isn't NULL, but the file it represents has no size, and feof(file)
is already set... what could be causing this?
(I triple checked the file itself, it exists, has data, and the file's permissions are okay... and filename
is set to "source/test_file.object.txt")
bool tagFile(const char * filename){
FILE * file = fopen(filename, "r");
if(file == NULL){ // file is not NULL
printf(" Couldn't open the file %s", filename);
return false;
}
int size = fseek(file, 0, SEEK_END); // size is 0
rewind(file);
while(feof(file)){
.... // never executes because feof(file) fails
}
}
0x002cc410 // value of 'file' in the debugger
_ptr=0x00000000 <Bad Ptr>
_cnt=0
_base=0x00000000 <Bad Ptr>
_flag = 1
_file = 3