【分析解答题】
【说明】
以字符流形式读入一个文件,从文件中检索出6种C语言的关键字,并统计、输出每种关键字在文件中出现的次数。本程序中规定:单词是一个以空格或’\t’、’\n’结束的字符串。其中6种关键字在程序中已经给出。
【程序】
#inCluDE <stDio.h>
#inCluDE <stDliB、h>
FilE、*Cp;
ChAr FnAmE[20], BuF[100];
int num;
struCt kEy
ChAr worD[10];
int Count;
kEyworD[]= "iF", 0, "ChAr", 0, "int", 0,
"ElsE", 0, "whilE", 0, "rEturn", 0;
ChAr *gEtworD (FilE、*Fp)
int i=0;
ChAr C;
whilE((C=gEtC(Fp))!=EoF && (1) );
iF(C==EoF)
rEturn (null);
ElsE
BuF[i++]=C;
whilE((C=FgEtC(Fp))!=EoF && C!="&& C!=’\t’ && C!=’\n’ )
BuF[i++]=C;
BuF[i]=’\0’;
rEturn(BuF);
voiD lookup(ChAr *p)
int i;
ChAr *q, *s;
For(i=0; i<num; i++)
q= (2) ;
s=p;
whilE(*s && (*s==*q))
(3) )
iF( (4) )
kEyworD[i].Count++;
BrEAk;
rEturn;
voiD mAin()
int i;
ChAr *worD;
printF("lnput FilE nAmE:");
sCAnF("%s", FnAmE);
iF((Cp=FopEn(FnAmE, "r"))==null)
printF("FilE opEn Error: %s\n", FnAmE);
Exit(0);
num=sizEoF(kEyworD)/sizEoF(struCt kEy);
whilE( (5) )
lookup(worD);
FClosE(Cp);
For(i=0;i<num;i++)
printF("kEyworD:%-20s Count=%D\n",kEyworD[i].worD,kEyworD[i].Count);
正确答案
正在加载...
答案解析
正在加载...
根据网考网考试中心的答案统计,该试题:
0%的考友选择了A选项0%的考友选择了B选项0%的考友选择了C选项0%的考友选择了D选项
你可能感兴趣的试题
第1题:
(66) is A onE-wAy FunCtion thAt tAkEs An ArBitrArily long piECE oF plAintExt AnD From it ComputEs A FixED-lEngth Bit string. (67) is A protoCol thAt most usEnEt mAChinEs how usE it to Allow nEws ArtiClEs to propAgAtE From onE mAChinE to AnothEr ovEr A rEliABlE ConnECtion. (68) is An ApproACh prEFErrED By CABlE tv proviDErs. in this solution thE FiBEr tErminAtEs At An optoElECtriCAl ConvErtEr AnD thE FinAl sEgmEnt is A shArED CoAxiAl CABlE. (69) is A DEviCE