/* p6.c */ #include int main() { FILE *f1; FILE *f2; int x; f1 = fopen("in.txt", "r"); if (f1 == 0) { perror("f1 failure:"); exit(1); } f2 = fopen("out.txt", "w"); if (f2 == 0) { perror("f2 failure:"); exit(2); } if (fscanf(f1, "%d", &x) != 1) { perror("scanf failure:"); exit(2); } fprintf(f2, "%d\n", x); }