I'm trying to read the contents of a file. I think that I'm getting an
"end-of-file" condition before the entire file is read. Below is my
function that reads in the file:
file_ptr=fopen(twod_file,"rb"); //done elsewhere outside the function
<CODE>
ReadEntireFile(file_ptr)
FILE *file_ptr;
{
register one_byte;
static long int count = 0;
printf("\n");
while( ( one_byte = getc(file_ptr) ) != EOF )
{
count++;
printf("%d", one_byte);
}
printf("\nerrno = %d", errno);
printf("\n");
printf("\ncount = %ld", count);
printf("\nfeof = %d", feof(file_ptr));
printf("\nferror = %d", ferror(file_ptr));
}
</CODE
Here is the output (with the file contents removed):
<OUTPUT>
errno = 0
count = 2093056
feof = 16
ferror = 0
</OUTPUT>
My file size is 2097152 bytes. I have verfied that not all of the
contents of the file are outputted. It seems as though I get and
"end-of-file" condition before I read the end of file.
Any help?
-Stephen