tok1.c
来自「稀疏矩阵、链表、图、队列、二叉树、多叉树、排序、遗传算法等的实现」· C语言 代码 · 共 33 行
C
33 行
#include <stdio.h>#include <string.h>voidtok(char *s, char *delim) { char *tmp; tmp = strtok(s, delim); while (tmp) { printf("token: %s\n", tmp); tmp = strtok(NULL, delim); }}intmain(void) { /* never used a fixed size buffer like this in real code! */ char buf[1024]; /* to eat the newline */ char *nl; while (fgets(buf, 1024, stdin)) { /* I consider the != NULL superfluous, but some compilers * will give a warning without it. */ if ((nl = strchr(buf, '\n')) != NULL) { /* no need for newline */ *nl = '\0'; } tok(buf, " "); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?