Ticket #4862: test.c
| File test.c, 347 bytes (added by , 8 years ago) |
|---|
| Line | |
|---|---|
| 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | |
| 4 | int main() |
| 5 | { |
| 6 | FILE * fp; |
| 7 | char buffer[10]; |
| 8 | fp = fopen ("file.txt", "w+"); |
| 9 | fputs("Hello.\n", fp); |
| 10 | rewind(fp); |
| 11 | fscanf(fp, "%s", buffer); |
| 12 | if (ferror(fp)) { |
| 13 | perror("Error reading file"); |
| 14 | } else { |
| 15 | printf("Read: %s\n", buffer); |
| 16 | } |
| 17 | fclose(fp); |
| 18 | return(0); |
| 19 | } |

