strange file reading problem in c++: fread()
Tag : cpp , By : user91848
Date : March 29 2020, 07:55 AM
Hope that helps I have a very strange problem when reading a binary file. objPath=new char[obLength + 1];
cout<<"i am at"<<ftell(f)<<endl;
fread(objPath,sizeof( char),obLength,f);
objPath[obLength]='\0';
|
Why using fread() the 2-nd time it reads a file not from beginning but from the end of reading by the 1-st fread()?
Tag : c , By : christiandsg
Date : March 29 2020, 07:55 AM
should help you out This is intended. fread always reads from the file's current read pointer and advances that same pointer, so you can a file in sequential chunks without having to explicitly seek. You shouldn't have to read the same chunk twice in a row. What you're checking this way is whether some other process has changed the file in the meantime, and if one has, then your program will erroneously report that the copy failed.
|
Strange value when reading from binary file with fread() in C
Date : March 29 2020, 07:55 AM
hop of those help? I have an issue that I can't solve... , I suspect your problem is on this line fwrite(tmpA->a3, sizeof(struct b), 1, file);
fwrite(tmpA->a2, sizeof(char), strlen(tmpA->a2), file);
fwrite(tmpA->a6, sizeof(char), strlen(tmpA->a6), file);
|
Strange Behavior When Reading From a File in C
Date : March 29 2020, 07:55 AM
should help you out I am trying to read the file "someNumbers" with this content (separator between numbers is a tab "\t"): , Where do you think fscanf(fb, "%*[^\t]%1s", dummy);
int retval = fscanf (fb, " %d", &number);
if (retval == 1) {
...got a number...
} else if (retval == EOF) {
...we're done...
} else {
...error...
}
|
Strange behavior in file reading in C
Date : March 29 2020, 07:55 AM
hope this fix your issue So I want to read some data from a csv file. , You have infinite loop inside while loop. if (count == 0) {
continue;
}
|