aihot  2020-11-12 10:31:54  OpenCV |   查看评论   
count; };

然后我们来声明一个结构数组,来保存C语言中的关键字:

struct key keytab[]={     "auto",0,     "break",0,     "case",0,     /* …… */     "while",0 };

6.4 指向结构的指针

将6.3中的拆半查找中传递数组的方法,换成传递指针的方法。

定义拆半查找的函数原型:

struct key *     binsearch(char *word,struct key *keytab,int n)

对比于数组形式的写法:

struct key *     binsearch(char *word,struct key keytab[],int n)

下是关键字列表拆半查找的程序:

struct key *     binsearch(char *word,struct key *            
          
 

除特别注明外,本站所有文章均为 赢咖4注册 原创,转载请注明出处来自《TCPL》 第6章 结构

留言与评论(共有 0 条评论)
   
验证码:
[lianlun]1[/lianlun]