LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 726|回复: 2

APUE的7-3程序的错误

[复制链接]
发表于 2003-12-29 20:40:08 | 显示全部楼层 |阅读模式
不知道错在哪里,请大家帮看看。
     1  #include "ourhdr.h"
     2  #define TOK_ADD  5
     3  void   do_line(char *);
     4  void   cmd_add(void) ;
     5  int    get_token(void);
     6  int main(void)
     7  {
     8     char    line[MAXLINE];
     9     while(fgets(line,MAXLINE,stdin) != NULL )
    10          do_line(line);
    11       exit(0);
    12     }
    13  char  *tok_ptr                  /* global pointer for get_token() */
     14 void
    15  do_line(char *ptr)              /* process one line of input      */
    16  {
    17     int    cmd;
    18     tok_ptr=ptr;
    19     while ((cmd=get_token()) >0) {
    20        switch(cmd) {     /* one case for each command */
    21        case TOK_ADD:
    22             cmd_add();
    23             break;
    24          }
    25      }
    26  }

    27  void
    28  cmd_add(void)
    29  {
    30     int   token;
    31     token=get_token();  /* rest of processing for this command  */
    32  }
    33  int
    34  get_token(void)
    35  {
    36       /* fetch next token from line pointed to by tok_ptr */
    37  }

R# gcc -c 7-3.c
7-3.c:14: syntax error before "void"
7-3.c: In function `do_line':
7-3.c:18: `tok_ptr' undeclared (first use in this function)
7-3.c:18: (Each undeclared identifier is reported only once
7-3.c:18: for each function it appears in.)
发表于 2003-12-30 00:15:50 | 显示全部楼层
显然是13行少了个分号
 楼主| 发表于 2003-12-30 14:18:02 | 显示全部楼层
thanks to you !!我太大意了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表