#include #include #include #include #include int main (void) { int fh1, fh2; unsigned int nbytes = 60000, bytesread; char fh1_IN[60000]; fh1 = open( "text.tst.c", O_RDONLY | O_TEXT ); dup2(fh1, 0); gets( fh1_IN ); bytesread = strlen(fh1_IN); printf( "read %u bytes from file\n", bytesread ); { unsigned int i; for (i=0; i< bytesread; i++) { printf( "char value: %i\t\t%c\n", fh1_IN[i], fh1_IN[i] ); } } close( fh1 ); fh1 = open( "text.tst.c", O_RDONLY | O_BINARY ); lseek( fh1, 0, SEEK_SET ); /* added to try to get the pointer back to the the beginning of the file. Which doesn't help. */ dup2(fh1, 0); gets( fh1_IN ); bytesread = strlen(fh1_IN); printf( "read %u bytes from file\n", bytesread ); { unsigned int i; for (i=0; i< bytesread; i++) { printf( "char value: %i\t\t%c\n", fh1_IN[i], fh1_IN[i] ); } } close( fh1 ); }