black

软件工程

登录

填空题

下面的程序用变量count统计文件letter.dat中字符的个数。请写出程序的横线处应该填入的内容。() 
#include  
main( ) 
{   FILE *fp; 
long count=0; 
if((fp=fopen((“letter.dat”,       ))==NULL){
     printf((“Cannot open file!\n”);
     exit(0); 
} 
while(!feof(fp)){
           ;
      count++; } 
printf((“count=%d\n”,count);
fclose(fp); 
}

【参考答案】

“r”;fgetc(fp)

相关考题

填空题 下列程序的输出结果是()。  #include   FUN(int **b,int p[2][3])   {      **b=p[1][1];  } main( )  {   int a[2][3]={2,4,6,8,10,12},*p;     p=(int *)malloc(sizeof(int));      FUN(&p,a);  printf(“%d\n”,*p);  }

填空题 下列程序的运行结果是()。      #include   #include   FUN(char *w,int n)  {   char temp,*s1,*s2; s1=w;  s2=w+n-1;  while(s1temp=*s1++;  *s1=*s2--;  *s2=temp;  }  }      main( )  {   char *p;  p=“1234567”;  FUN(p,strlen(p));  puts(p);  }

填空题 执行下列程序的输出结果是()。  #include   #include    main( )  {   char a[80]=“AB”, b[80]= “LMNP”;       int i=0;      strcat(a,b);      while(a[i++]!=‘\0’)          b[i]=a[i];  puts(b); }

All Rights Reserved 版权所有©财会考试题库(ckkao.com)

备案号:湘ICP备2022003000号-2