有以下程序:#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]
举一反三
- 有以下程序:#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] A: 321 B: 12300 C: 1 D: 123
- 有以下程序:#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] A: 321 B: 12300 C: 1 D: 123
- 有以下程序:#include stdio.hmain(){ FILE *fp; int a[10]={1,2,3}, i, n;fp = fopen(d1.dat, w);for (i=0; i3; 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] A: 321 B: 12300 C: 1 D: 123
- 下列程序的输出结果是( ) int main(void) { FILE *fp; int i,k,n; fp=fopen("data.dat","w+"); for(i=1;i<6;i++) { fprintf(fp,"%d",i); if(i%3==0) fprintf(fp,"\n"); } rewind(fp); fscanf(fp,"%d%d",&k,&n); printf("%d%d\n",k,n); fclose(fp); return 0;}
- 有以下函数:voidf(){FILE*fp;inti,n=0,k=0;fp=fopen(“source.txt”,”w”);for(i=0;i<5;i++)fprintf(fp,”%d”,i);fclose(fp);fp=fopen(“source.txt”,”r”);fscanf(fp,”%d%d”,&n,&k);printf(“%d,%d”,n,k);fclose(fp);}输出结果为()