更多"以下程序用业统计文件十字符个数。请填空。 #include 'st"的相关试题:
[填空题]以下程序用以删除字符串中所有的空格,请填空。
#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];i++;)
s[j]=______;
printf("%s/n",s);
[填空题]以下程序用来统计文件中字符个数。请填空。
#include "stdio. h"
main( )
FILE *fp;long num=OL;
if((fp=fopen("fname.dat","r")==NULL)
Pirntf("Open error/n"); exit(0);
while( 【16】 )
fgetc(fp);num++;
printf("num=%1d/n",num-1);
fclose(fp);
[填空题]以下程序的功能是:删除字符串中所有的空格。请填空。
#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( )
long count=OL;
FILE*fp= 【16】 ("text.dat","r");
if(fp==0)
printf("Open error/n");
exit(0);
while( 【17】 )
fgetc(fp);
count++;
fclise(fp);
printf("%1d/n",count);
[填空题]以下程序用来判断指定文件是否能正常打开。请填空。
#include <stdio.h>
main( )
FILE *fp;
if(((fp=fopen("test.txt","r"))==______))
printf("未能打开文件!/n");
else
printf("文件打开成功!/n");
[填空题]
有以下程序(说明:字符0的ASCII码值为48)
#include
main( )
{ charc1,c2;
scanf("%d",&c1);
c2=c1+9;
printf("%c%c/n",c1,c2);
}
若程序运行时从键盘输入48<回车>,则输出结果为()。
[填空题]
以下程序运行后的输出结果是()。
#include
#include
#include
main( )
{ char *p;int i;
p=(char*)malloc(sizeof(char)*20);
strcpy(p,"welcome");
for(i=6;i>=0;i--) putchar(*(p+i));
printf("/n"); free(p);
}
[填空题]下列程序用来判断指定文件是否能正常打开,请填空。
#include<stdio.h>
main( )
FILE*fp;
if(((fp=fopen("test.txt","r")==______))
prinff("文件打开成功!/n");
else
printf("未能打开文件!/n");
[填空题]下列程序的输出结果是16.00,请填空。
#include <stdio.h>
main( )
int a=9, b=2;
float x= 【12】 ,y=1.1,z;
z=a/2+b*x/y+1/2;
printf("%5.2f/n",z);
[单项选择]有以下程序
#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
[填空题]以下函数把b字符串连接到a字符串的后面,并返回a中新字符串的长度。请填空。
strcen(char a[],char b[])
{ int num=0,n=0;
while(*(a+num)! = 【15】 )num++;
while(b[n]){*(a+num)=b[n];num++; 【16】 ;}
return(num);
}
[填空题]以下函数把b字符串连接到a字符串的后面,并返回a中新字符串的长度。请填空。
surcen(chara[],char b[])
{ int num=0,n=0;
while(*(a+num)!=______)num++;
while(b[n]){*(a+num)=b[n];num++;______;}
return(num);
} _’/o’或0
[填空题]以下函数把b字符串连到a字符串的后面,并返回a中新字符串的长度,请填空。
strcen(char a[],char b[])
{
int num=0,n=0;
while(*(a+num)!= 【13】 )num++;
while(b[n]){*(a+num)=b[n];num++; 【14】 ;}
return num;
}
[填空题]以下函数把b字符串连接到a字符串的后面,并返回a中新字符串的长度。请填空。
surcen(chara[],char b[])
int num=0,n=0;
while(*(a+num)!=______)num++;
while(b[n])*(a+num)=b[n];num++;______;
return(num);
_’/o’或0
[单项选择]有以下程序
#include
main( )
{struct STU{char name[9];char sex;double score[2]; };
struct STU a={"Zhao",m’’,85.0,90.0},b={"Qian",f’’,95.0,92.0};
b=a:
printf("%s,%c,%2.0f,%2.0f/n",b.name,b.sex,b.score [0],b.score[1]);
}
程序的运行结果是
A. Qian,f,95,92
B. Qian,m,85,90
C. Zhao,f,95,92
D. Zhao,m,85,90