更多"有以下程序:
#include
main( )
{ FILE "的相关试题:
[单项选择]有以下程序
#include
main( )
FILE *fp;int i=20,j=30,k,n;
fp=fopen("d1.dat","w");
fprintf(fp,"%d/n",i);fprintf(fp,"%d/n",j);
fclose(fp);
fp=fopen("d1.dat","r");
fscanf(fp,"%d%d",&k,&n);printf("%d%d/n",k,n);
fclose(fp);
程序运行后的输出结果是
A. 20 30
B. 20 50
C. 30 50
D. 30 20
[单项选择]有以下程序:
#include
main( )
FILE *fp;int k,n,a[6]=1,2,3,4,5,6;
fP=fopen(¨d2.dat¨,¨W¨);
fprintf(fp,¨%c1%d%d/n¨,a[0];a[1],a[2]);
fprintf(fp,¨%c1%d%d/n¨,a[3],a[4],a[5]);
fdose[fp);fp=fopen(¨d2.dat¨,¨r¨);
fscanf(fp,¨%d%d¨,&k,&n);
printf(¨%d%d/n¨,k,n);
fclose(fp);
程序运行后的输出结果是( )。
A. 1
B. 12 4
C. 123 4
D. 123 456
[单项选择]有以下程序:
#include
main( )
{ 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);
}
程序运行后的输出结果是______。
A. 0 0
B. 123 45
C. 1 4
D. 1 2
[单项选择]有以下程序
#include
main( )
{ FILE *fp;int i=20,j=30,k,n;
fp=fopen("d1.dat","w");
fprintf(fp,"%d/n",i);fprintf(fp,"%d/n",j);
fclose(fp);
fp=fopen("d1.dat","r");
fscanf(fp,"%d%d",&k,&n);printf("%d%d/n",k,n);
fclose(fp);}
程序运行后的输出结果是
A)20 30 B)20 50 C)30 50 D)30 20
[填空题]
以下程序运行后的输出结果是()。
#include
main( )
{ FILE *fp;int x[6]={1,2,3,4,5,6},i;
fp=fopen("test.dat","wb");
fwrite(x,sizeof(int),3,fp);
rewind(fp);
fread(x,sizeof(int),3,fp);
for(i=0;i<6;i++) printf("%d",x[i]);
printf("/n");
fclose(fp);
}
[单项选择]有以下程序:
#include<stdio.h>
main( )
FILE *fp;int i=20,j=30,k, n;
fp=fopen("d1.dat","w");
fprintf(fp,"%d/n",i);
fprintf(fp,"%d/n",j);
fclose(fp);
fp=fopen("d1.dat","r");
fscanf(fp,"%d%d",&k,&n);
printf("%d%d/n",k,n);
fclose(fp);
程序运行后的输出结果是( )。
A. 20 30
B. 20 50
C. 30 50
D. 30 20
[单项选择]有以下程序
#include<stdio.h>
main( )
FILE *fp;int i=20,j=30,k,n;
fp=fopen("d1.dat","w");
fprintf(fp,"%d/n",i);fprintf(fp,"%d/n",j);
fclose(fp);
fp=fopen("d1.dat","r");
fscanf(fp,"%d%d",&k,&n);printf("%d%d/n",k,n);
fclose(fp);
程序运行后的输出结果是( )。
A. 20 30
B. 20 50
C. 30 50
D. 30 20
[单项选择]有以下程序:
#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);
fdose(fp);
printf("%d/n",n);
A. 12300
B. 123
C. 1
D. 321