更多"以下程序用来统计文件中字符个数。请填空。
#include 'st"的相关试题:
[填空题]以下程序用来统计文件中字符的个数。请填空。
#include“stadio.h”
main( )
FILE *fp;long num=0L;
if((fp=fopen(“fname.dat”,“r”))==NULL);
printf(“0pen error/n”);exit(0);
while( 【16】 )
fsetc(fp);num++;
printf(“num=%1d/n”,num-1);
fclose(fp);
[填空题]以下程序用来统计文件字符的个数,请填空。
#include<stdio.h>
#include<string>
void main( )
FILE *fp;long num=0;
if ((fp=fopen("fname.dat"," r"))==NULL)
printf("Open error/n");
exit(0),
while(______)
fgetc(fp);num++;
printf("num=%1d/n",num-1);
fclose(fp);
[填空题]
以下程序用来判断指定文件是否能正常打开,请填空。
#include<stdio.h>
main( )
{FILE*fp;
if(((fp=fopen("test.txt","r"))=()))
printf("未能打开文件!/n");
else
printf("文件打开成功!/n");
}
[填空题]下列程序用来判断指定文件是否能正常打开,请填空。
#include<stdio.h>
main( )
(FILE *fp;
if(((fp=fopen("test.txt","r")!=______))
printf("文件打开成功!/n");
else
printf("未能打开文件!/n");
[填空题]下面程序可用来统计文件中字符的个数。
#include<stdio.h>
main( )
{FILE *fp;
long num=0;
if((fp=______)==NULL)/*第一空*/
{printf("Can not open file/n");exit(0);}
while(______)/*第二空*/
{______;}/*第三空*/
printf("num=%d/n",num);
fclose(fp);
}
[填空题]
以下程序用以删除字符串所有的空格,请填空。
#include
main( )
{ char s[100]={"Our teacher teach C language!"};int i,j;
for(i=j=0;s[i]!=’/0’;i++)
if(s[i]!= ’ ’) {s[j]=s[i];j++;}
s[j]= ()
printf(“%s/n”,s);
}
[填空题]以下程序用来判断指定文件是否能正常打开。请填空。
#include<stdio.h>
main( )
{ FILE *fp;
if(((fp=fopen("test.txt", "r"))==______))
printf("未能打开文件!/n");
else printf("文件打开成功!/n");
}
[填空题]以下程序的功能是计算字符串的长度。请填空。
#include<stdio.h>
main( )
{char str[100],*sp=str;
int nlen=0;
scanf("%s",str);
for(;*sp!=’/0’;sp++)______;
printf("%d",nlen);
}
[填空题]以下程序是用来统计正整数的每位数字中零的个数,并求每位数字中最大者。请填空。
main( )
unsigned long num,max,t;
int count;
count=max=0:
scanf("%ld",&num);
do
t=______;
if(t==0)++count;
else if(max<t)max=t;
num/=10;
while(num);
printf("count=%d,max=%ld/n",count,max);
[填空题]以下程序用以删除字符串所有的空格,请填空。
#include <stdio.h>
main( )
char s[100]= "Our teacher teach C language!");int i,j;
for(i=j=0;s[i]!=’/0’;i++)
if(s[i]!=’’)s[j]=s[i];j++;
s[j]=______;
printf("%s/n",s);
[填空题]以下程序用以删除字符串中所有的空格,请填空。
#include <stdio.h>
main( )
char s[100]="our teacher teach c language!”;int i,j;
for(i=j=0;s[i]!=’/0’;i++)
if(s[i]!=’’) s[j]=s[i];j++;
s[j]=______;
printf("%s/n",s);
[单项选择]有以下程序
#include
main( )
{FILE *fp; int i;
char ch[]="abcd",t;
fp=fopen("abc.dat", "wb+");
for(i=0;i<4;i++)fwrite(&ch[i],1,1,fp);
fseek(fp,-2L,SEEK_END);
fread(&,1,1,fp);
fclose(fp);
printf("%c\n",t);
}
程序执行后的输出结果是【 】。
A. d
B. c
C. b
D. a