藍森林首頁 | 返回主頁 | 本站地圖 | 站內搜索 | 聯繫信箱 |
 您目前的位置:首頁 > 自由軟件 > 技術交流 > 應用編程


    

藍森林 http://www.lslnet.com 2006年6月6日 10:18


APUE的7-3程序的錯誤

不知道錯在哪裡,請大家幫看看。
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.)

APUE的7-3程序的錯誤

13 char *tok_ptr /* global pointer for get_token() */

tok_ptr  後面要有個分號; 印刷錯誤?

APUE的7-3程序的錯誤

能貼出這個錯誤的人不簡單



Copyright © 1999-2000 LSLNET.COM. All rights reserved. 藍森林網站 版權所有。 E-mail : webmaster@lslnet.com