#include
#include
#define SIZE 50
void main()
{
char str[SIZE] = "the result of last game : computer win";
FILE *fp = fopen("data.txt", "w+");
fputs(str, fp);
memset(str, 0, SIZE);
rewind(fp);
fgets(str, SIZE-1, fp);
puts(str);
fclose(fp);
}
#include
main()
{FILE *fp;
char a[100]="the result of last game : computer win",b[100];
fp=fopen("d://www.txt","w");
fprintf(fp,"%s",a);
fclose(fp);
fp=fopen("d://www.txt","r");
fscanf(fp,"%s",b);
fscanf(stdout,"%s",b);
fclose(fp);
}
哦, 对了,用fprintf和fscanf可以实现