linux命令strace,str函数详解
strsep函数用于分割字符串,函数原型如下:
char *strsep(char **s, const char *ct);
s为指向欲分割的字符串,ct为分隔符,函数将返回分隔符前面的字符串,s将指向分隔符之后的字符串,实例如下:
#include <stdio.h>
#include <string.h>
int main(void)
{
char s[] = "hello world!";
char *p = s;
char *d = " ";
printf("%s\n", strsep(&p, d));
printf("%s\n", p);
return 0;
}
函数打印如下:
hello
world!