Quote:
Between doing a 'write' to the file and doing a 'read', you have to do a fflush(test)
You also need to do a fseek() as well, to get the position back to where you expect the data to start.
i remember writing and reading to the file without using any of the functions you mentioned. are they needed for simple strings?
Quote:
Quote:
my little concern is: getchar() is supposed to pause the program until i hit enter, why doesn't it work with some programs? like this one?
It doesn't work when there's already a character sitting in the input buffer (such as a newline from a scanf() call). So you probably didn't post the whole program? Anyway, to clear the input buffer, try this:
actually i did post the full code. but what is the while loop for? how will it clear the input buffer?
Quote:
> 2. why isn't fprintf write to the file?
I think it probably is. The thing is, the stream pointer is at the pointer after where you just wrote Testing so your fscanf() is trying to read data that isn't there. Try putting rewind(test); between your fprintf() and fscanf() calls.
that problem would only happen if i'm trying to read the file using fscanf. i know i am but i'm also opening the file using notepad and it's just empty.