Posted on 2010-09-15 13:56
Prayer 閱讀(1499)
評論(0) 編輯 收藏 引用 所屬分類:
C/C++
原型:char *strsep(char **stringp, const char *delim);
功能:分解字符串為一組字符串。
示例:
#include <stdio.h>
#include <string.h>
int main(void)
{
char str[] = "root:x::0:root:/root:/bin/bash:";
char *buf;
char *token;
buf = str;
while((token = strsep(&buf, ":")) != NULL){
printf("%s\n", token);
}
return 0;
}