Linux strsep() 用法

strsep(),作为strtok的升级版,是一个很有用的字符串处理函数

man strsep:

#include <string.h>  

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

Be cautious when using this function. If you do use it, note that:  

This function modifies its first argument.  

This function cannot be used on constant strings.  

The identity of the delimiting character is lost.

#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;
}
函数打印如下:helloworld!


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值