C++ Builder有没有字符串切割的函数Split-CSDN论坛
2个回答
展开全部
C/C++中有strtok()其函数实现上述的功能:
/* strtok example */
#include <stdio.h>
#include <string.h>
int main ()
{
char str[] = "aaa bbb ccc ddd eee fff";
const char * split = " ";
char * p;
p = strtok (str,split);
while(p!=NULL) {
printf ("%s\n",p);
p = strtok(NULL,split);
}
/* strtok example */
#include <stdio.h>
#include <string.h>
int main ()
{
char str[] = "aaa bbb ccc ddd eee fff";
const char * split = " ";
char * p;
p = strtok (str,split);
while(p!=NULL) {
printf ("%s\n",p);
p = strtok(NULL,split);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询