while (!feof(openfile))
{
str = fgetc(openfile);
str = str + '\10';
fputc(str, openfile);
printf("%c", str);
if (ferror(openfile))
{
perror("Read error");
break;
}
a = feof(openfile);
printf("%d",a );
}
http://www.cnblogs.com/ayanmw/archive/2012/09/12/2682016.html
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
int count, total = 0;
char buffer[100];
FILE *stream;
if( (stream = fopen( "feof.c", "r" )) == NULL )
exit( 1 );
/* Cycle until end of file reached: */
while( !feof( stream ) )
{
/* Attempt to read in 10 bytes: */
count = fread( buffer, sizeof( char ), 100, stream );
if( ferror( stream ) ) {
printf( "Read error" );
break;
}
/* Total up actual bytes read */
total += count;
}
printf( "Number of bytes read = %d\n", total );
fclose( stream );
}