#include <stdio.h>
#include <stdlib.h>
void fun(char *s, int a, double f)
{
/**********found**********/
FILE * fp;//“fp=fopen("file1.txt", "w");”可知fp是文件型指针,fp的定义应为“FILE *”。
char str[100], str1[100], str2[100];
int a1; double f1;
fp = fopen("file1.txt", "w");
fprintf(fp, "%s %d %f\n", s, a, f);
/**********found**********/
fclose(fp);//在第二次打开file1.txt之前必须将文件关闭
fp = fopen("file1.txt", "r");//再次打开file1.txt
/**********found**********/
fscanf(fp,"%s%s%s", str, str1, str2);//fscanf的调用形式是:fscanf(fp,格式字符串,输入列表),因此第三空处应为“fp”,从文件当中读出字符串、整数、浮点数。
fclose(fp);
a1 = atoi(str1);
f1 = atof(str2);
printf("\nThe result :\n\n%s %d %f\n", str, a1, f1);
}
main()
{char a[10]="Hello!"; int b=12345;
double c= 98.76;
fun(a,b,c);
}