I've been reading characters from text files but I have been using a loop that uses
to read into whatever I want it to read into. However, I know this is not the proper way to do it.Code:while(!feof(filename))
I'm supposed to be using the return code of whatever I am using to read from the file, right?
So I am using fscanf and reading 1 character at a time....how do I loop with fscanf? I guess my question is what does fscanf return when it reaches the end of a file. The code below is simply what my guess is at what it will be like.
Code:while( (fscanf(filename, "%c", &next_char) != ???) ) { work with data here }



LinkBack URL
About LinkBacks



