设有定义:char c[]="Cc"; FILE *fp;且fp指向以"写文本文件"的方式成功打开的文件,若要将c中的两个字符写入文件,且每个字符占一行,则下面的选项中正确的是______。
A: fprintf(fp,"%c\n%c\n",c[0],c[1]);
B: fprintf(fp,"%c\N\n%c\N\n",c[0], c[1]);
C: fprintf (fp, "%c %c"%,c[0],c[1]);
D: fprintf(fp,"%s\n",c);
A: fprintf(fp,"%c\n%c\n",c[0],c[1]);
B: fprintf(fp,"%c\N\n%c\N\n",c[0], c[1]);
C: fprintf (fp, "%c %c"%,c[0],c[1]);
D: fprintf(fp,"%s\n",c);
举一反三
- 有以下程序:#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
- 下列程序的输出结果是( ) 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;}
- 有以下程序:#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
- 有以下程序:#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]