请高手帮忙看看。急!!!!
来源:百度知道 编辑:UC知道 时间:2024/07/04 11:58:45
若输入string 12,下列程序输出结果为_______
#include<stdio.h>
main()
{char s[80];
int a;
FILE *fp;
if ((fp=fopen(“test”,”w”))==NULL)
{puts(“cannot open the file”);
exit();
}
fscanf(stdin,”%s%d”,s,&a);
fprintf(fp,”%s%d”,s,a);
fclose(fp);
if((fp=fopen(“test”,”t”))==NULL)
{puts(cannot open the file”);
exit();
}
fscanf((fp,”%s%d”,s,&a);
fprintf(stdout,”%s%d\n”,s,a);
fclose(fp);
}
#include<stdio.h>
main()
{char s[80];
int a;
FILE *fp;
if ((fp=fopen(“test”,”w”))==NULL)
{puts(“cannot open the file”);
exit();
}
fscanf(stdin,”%s%d”,s,&a);
fprintf(fp,”%s%d”,s,a);
fclose(fp);
if((fp=fopen(“test”,”t”))==NULL)
{puts(cannot open the file”);
exit();
}
fscanf((fp,”%s%d”,s,&a);
fprintf(stdout,”%s%d\n”,s,a);
fclose(fp);
}
#include<stdio.h>
#include<stdlib.h>
main()
{char s[80];
int a;
FILE *fp;
if ((fp=fopen("test","w"))==NULL)
{puts("cannot open the file");
exit(0);
}
fscanf(stdin,"%s%d",s,&a);
fprintf(fp,"%s%d",s,a);
fclose(fp);
if((fp=fopen("test","t"))==NULL) // t 你没定是读还是写 。这个文件。。t表示文本文件。 要加 r 或 w。
{puts("cannot open the file"); 所以输出 :cannot open the file
exit(0);
}
fscanf(fp,"%s%d",s,&a);
fprintf(stdout,"%s%d\n",s,a);
fclose(fp);
}