fig7.9
来自「UNIX环境高级编程书的源代码」· 9 代码 · 共 50 行
9
50 行
#include "apue.h"#define TOK_ADD 5void do_line(char *);void cmd_add(void);int get_token(void);intmain(void){ char line[MAXLINE]; while (fgets(line, MAXLINE, stdin) != NULL) do_line(line); exit(0);}char *tok_ptr; /* global pointer for get_token() */voiddo_line(char *ptr) /* process one line of input */{ int cmd; tok_ptr = ptr; while ((cmd = get_token()) > 0) { switch (cmd) { /* one case for each command */ case TOK_ADD: cmd_add(); break; } }}voidcmd_add(void){ int token; token = get_token(); /* rest of processing for this command */}intget_token(void){ /* fetch next token from line pointed to by tok_ptr */}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?