getcols.c
来自「稀疏矩阵、链表、图、队列、二叉树、多叉树、排序、遗传算法等的实现」· C语言 代码 · 共 30 行
C
30 行
/**************************************/
/* */
/* Code from the book C Unleashed */
/* Macmillan, 2000 */
/* Chapter 6: Data Files */
/* Steve Summit 2000-03-17 */
/* */
/**************************************/
#include <string.h>
int getcols(char *line, char *words[], int maxwords, int delim)
{
char *p = line, *p2;
int nwords = 0;
while(*p != '\0')
{
words[nwords++] = p;
if(nwords >= maxwords)
return nwords;
p2 = strchr(p, delim);
if(p2 == NULL)
break;
*p2 = '\0';
p = p2 + 1;
}
return nwords;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?