求助!!!!C语言高手一个小问题(急在线等!!!)

2024-11-17 03:51:59
推荐回答(3个)
回答(1):

#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);
}

回答(2):

#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);
}

回答(3):

哦, 对了,用fprintf和fscanf可以实现