|
|
1.1 ! root 1: #include <stdio.h> ! 2: ! 3: main () ! 4: { ! 5: FILE *fp; ! 6: char let[4]; ! 7: ! 8: /* open file into write/read mode */ ! 9: if ((fp = fopen("tmpfile", "wr")) == NULL) { ! 10: printf("Cannot open 'tmpfile'\n"); ! 11: exit(1); ! 12: } ! 13: ! 14: /* write a string of chars into file */ ! 15: fprintf(fp, "1234"); ! 16: ! 17: /* move file pointer back to beginning of file */ ! 18: rewind(fp); ! 19: ! 20: /* read and print data from file */ ! 21: fscanf(fp, "%c %c %c %c", ! 22: &let[0], &let[1], &let[2], &let[3]); ! 23: printf("%c %c %c %c\n", ! 24: let[3], let[2], let[1], let[0]); ! 25: exit(0); ! 26: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.