以下程序执行后,文件test.txt的内容是() #include void main() { FILE *fp; fp=fopen(“test.txt”,”w”); fprintf(fp,”%s”,”How ”); fclose(fp); fp=fopen(test.txt“,”a”); fprintf(fp,”%s”,”are you!”); fclose(fp); }
举一反三
- 以下程序的功能是()。#includestdio.hintmain(void){FILE*fp;charstr[]=”hello”;fp=fopen(“prn.txt”,”w”);fprintf(fp,”%s”,str);fclose(fp);return0;}
- 请在______填上适当内容,完成如下程序:int main(void){ FILE * fp; char str[10]; scanf("%s",str); if ((fp=fopen(str,"w"))!=______){ fprintf(fp,“%s”,str); fclose(fp); } return 0; }
- 请在______填上适当内容,完成如下程序:int main(void){ FILE * fp; char str[10]; scanf("%s",str); if ((fp=fopen(str,"w"))______ NULL){ fprintf(fp,“%s”,str); fclose(fp); } return 0; }
- 以下程序运行后,data.txt文件中的内容是() #include "stdio.h" int main() {FILE *fp; int a=15,b; fp=fopen("d:\data.txt","w"); fprintf(fp,"%d,",a); b=a+10; fprintf(fp,"%d ",b); fclose(fp); getch(); return 0; }
- 有以下程序:#include [stdio.h] main() { FILE *fp; int a[10]={1,2,3}, i, n; fp = fopen("d1.dat", "w"); for (i=0; i<3; i++) fprintf(fp, "%d", a[i]); fprintf(fp, "\n"); fclose(fp); fp = fopen("d1.dat", "r"); fscanf(fp, "%d", &n); fclose(fp); printf("%d\n", n); }程序的运行结果是()。[/i]