69,373
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
typedef unsigned char BYTE;
FILE *f;
BYTE fInByte;
long offset;
void main() {
f = fopen("upper.tif", "rb");
if (NULL==f) {
printf("Can not open upper.tif\n");
} else {
offset=0;
whlie (1) {
fInBytes = fgetc(f);
if (EOF==fInByte) break;
printf("%08ld:%02x\n",offset,fInByte);
offset++;
}
fclose(f);
}
}
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
FILE *stream;
char buffer[81];
int i, ch;
/* Open file to read line from: */
if( (stream = fopen( "fgetc.c", "r" )) == NULL )
exit( 0 );
/* Read in first 80 characters and place them in "buffer": */
ch = fgetc( stream );
for( i=0; (i < 80 ) && ( feof( stream ) == 0 ); i++ )
{
buffer[i] = (char)ch;
ch = fgetc( stream );
}
/* Add null to end string */
buffer[i] = '\0';
printf( "%s\n", buffer );
fclose( stream );
}