C programming 问题
登录 | 论坛导航 -> 华新鲜事 -> 社会百科 | 本帖共有 4 楼,当前显示第 2 楼 : 从楼主开始阅读 : 本帖树形列表 : 返回上一页
作者:chancing (等级:3 - 略知一二,发帖:750) 发表:2004-03-29 23:30:32  2楼 
rephraze ur question a bit
strsep
Syntax
#include <string.h>

char *strsep(char **stringp, char *delim);

Description
This function retrieves the next token from the given string, where stringp points to a variable holding, initially, the start of the string. Tokens are delimited by a character from delim. Each time the function is called, it returns a pointer to the next token, and sets *stringp to the next spot to check, or NULL.

Return Value
The next token, or NULL.

Portability
not ANSI, not POSIX

Example
main()
{
char *buf = "Hello there,stranger";
char **bp = &buf;
char *tok;
while (tok = strsep(bp, " ,"))
printf("tok = `%s'\n", tok);
}

tok = `Hello'
tok = `'
tok = `there'
tok = `stranger'

团结努力,不怕牺牲,排除万难.
我们要发达.
 

欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表

本帖共有 4 楼,当前显示第 2 楼,本文还有 N-1 层楼,要不你试试看:点击此处阅读更多 >>



请登录后回复:帐号   密码