http://bbs.bc-cn.net/viewthread.php?tid=149760&extra=&page=1这里有对文件的保存。。
如果你要显示上次保存的数据。。那么必须用读文件的一个函数fgetc来依次读,,,
例如
#include <string.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
FILE *stream;
char string[] = "This is a test";
char ch;
stream = fopen("DUMMY.FIL", "w+");
fwrite(string, strlen(string), 1, stream);
fseek(stream, 0, SEEK_SET);
do
{
ch = fgetc(stream);
putch(ch);
}
while (ch != EOF);
fclose(stream);
return 0;
}
也可用fgets函数来读一行字符
例如
#include <string.h>
#include <stdio.h>
int main(void)
{
FILE *stream;
char string[] = "This is a test";
char msg[20];
stream = fopen("DUMMY.FIL", "w+");
fwrite(string, strlen(string), 1, stream);
fseek(stream, 0, SEEK_SET);
fgets(msg, strlen(string)+1, stream);
printf("%s", msg);
fclose(stream);
return 0;
}