strtok strtok_r
分解字符串为一组字符串。s为要分解的字符串,delim为分隔符字符串。首次调用时,s指向要分解的字符串,之后再次调用要把s设成NULL。
#include<string.h>#include<stdio.h>intmain(void){charinput[16]="abc,d";char*p;/**//*strtokplacesaNULLterminatorinfrontofthetoken,iffound*/p=strtok(input,",");if(p)printf("%s\n",p);/**//*AsecondcalltostrtokusingaNULLasthefirstparameterreturnsapointertothecharacterfollowingthetoken*/p=strtok(NULL,",");if(p)printf("%s\n",p);return0;}
strtok_r
2458

被折叠的 条评论
为什么被折叠?



