// Program demonstrating strange effects of mixing C std and Unix // system I/O. Typical output is // // FIRST: 1 // NEXT: 41 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 // // which is explainable with internal buffering of C std I/O #include #include int main(int argc, char *argv[]){ FILE *input = fopen("3K.txt","r"); int first; fscanf(input, "%d", &first); printf("FIRST: %d\n",first); int fd = fileno(input); char *buf[64]; read(fd, buf, 63); buf[127] = '\0'; printf("NEXT: %s\n",buf); return 0; }