- 3
- 0
- 约2.08千字
- 约 2页
- 2023-04-30 发布于上海
- 举报
指向结构的指针
为了进一步说明指向结构的指针和结构数组,我们重新编写关键字统计程序,这次采用指针,而不使用数组下标。
keytab的外部声明不需要修改,但main和binsearch函数必须修改。修改后的程序如下:
#include stdio.h #include ctype.h #include string.h #define MAXWORD 100
int getword(char *, int);
struct key *binsearch(char *, struct key *, int);
/* count C keywords; pointer version */ main()
{
char word[MAXWORD]; struct key *p;
while (getword(word, MAXWORD) != EOF) if (isalpha(word[0]))
if ((p=binsearch(word, keytab, NKEYS)) != NULL) p-count++;
for (p = keytab; p keytab + NKEYS; p++) if (p-count 0)
printf(%4d %s\n, p-count, p-word); return 0;
}
/* binsearch: find word in tab[0]...
您可能关注的文档
最近下载
- 部编版六年级上册《道德与法治》课后练习题及答案(全册).pdf VIP
- 外教社中国概况(英文版)PPT课件CHAPTER-9.pptx VIP
- 2026年贵州水投水务集团有限公司招聘笔试真题及答案.docx VIP
- 48万吨磷酸二铵建设环境影响评估报告,.doc VIP
- 《进场和出场——参观16间交易室》中英对照版word+1-7+章.doc VIP
- 急性心肌梗死应急预案与流程.pptx VIP
- 一元二次方程100道计算题练习(附答案)+一元二次方程经典练习题(6套)附带详细答案.docx VIP
- 中国文化概况(英汉对照版)符存-11.第十一章 中国的创造.pptx VIP
- 中国文化概况(英汉对照版)符存-3.第三章 中国家庭.pptx VIP
- 雪之梦(Snow Dreams,钢琴谱)调钢琴谱五线谱.pdf VIP
原创力文档

文档评论(0)