#include
<string.h> #include
<stdio.h> #include
<conio.h> int
main(void) { FILE *stream; char string[ ] =
"This is a test"; int ch; /*
open a file for update */ stream
= fopen("DUMMY.FIL", "w+"); /*
write a string into the file */ fwrite(string, strlen(string), 1,
stream); /*
seek to the beginning of the file */ fseek(stream, 0, SEEK_SET); do { /* read a char from the file */ ch = fgetc(stream); /* display the character */ putch(ch); }
while (ch !=
EOF); fclose(stream); return 0;}原文:http://www.cnblogs.com/alsofly/p/3725224.html