帮忙看看一下的C语言程序!

来源:百度知道 编辑:UC知道 时间:2024/06/08 17:12:20
(在横线部分填写内容,也可以适当修改程序)
下面的程序以字符流形式读入一个文件,从中检索出C语言的6种类型定义符,并统计输出每种关键字在文件中出现的次数。为了简化运算,程序中规定以空格、“\t”或“\n”作为字符串的结束,请调试该程序。
#include<stdio.h>
#include<string.h>
FILE *cp;
char fname[20],buf[100];
int num;

struct key
{
char word[10];
int count;
}keyword[]={"int",0,"float",0,"char",0,"double",0,"enum",0,"struct",0};

char *getword(FILE *fp)
{
char c;
int i=0;
while((c=getc(fp))!=EOF&&(c==''||c=='\t'||c=='\n'));
if(c==EOF) return(0);else buf[i++]=c;
while((c=_______)!=EOF&&(c==''||c=='\t'||c='\n'))
buf[i++]=c;
buf[i]='\0';
return (buf);
lookup(char *p)
{
int i;
char *q,*s;
for(i=0;i<num;i++){
q=&keyword[i].word[0];
s=p;
while(*s&&(*s==*q))
{______

#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>

FILE *cp;
char buf[100];
char c='A';

struct key
{
char word[10];
int count;
}keyword[6]={"int",0,"float",0,"char",0,"double",0,"enum",0,"struct",0};

char *getword(FILE *fp)
{

int i=0;

while((c=fgetc(fp))!=EOF)
{
if(c==' '||c=='\t'||c=='\n')

{ buf[i]='\0';
return buf;
}
buf[i++]=c;
}

// while((c=_______)!=EOF&&(c==''||c=='\t'||c='\n')) ??
//buf[i++]=c;

return buf;
}

void lookup(char *p)
{
int i;

char word[10];

for(int j=0;*p!='\0';j++)
{
word[j]=*p++;