更多"有以下程序
#include
main( )
"的相关试题:
[单项选择]有以下程序
#include
main( )
{FILE * fp;int i,a[6]={l,2,3,4,5,6};
fp=fopen("d3.dat","W+b");
fwrite(a,sizeof(int),6,fp);
fseek(fp,sizeof(int)* 3,SEEK_SET);/*该语句使读文件的位置指针从文件头向后移动3个int型数
据*/
fread(a,sizeof(int),3,fp);fclose(fp);
for(i=0;i<6;i++)printf("%d,",a[i]);
}
程序运行后的输出结果是【 】。
A. 4,5,6,4,5,6,
B. 1,2,3,4,5,6,
C. 4,5,6,1,2,3,
D. 6,5,4,3,2,1,
[单项选择]有以下程序
#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 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