您的位置:首页 > 编程语言 > C语言/C++

C语言 对字符串进行分割

2015-11-30 12:46 323 查看
#include <stdlib.h>
#include <stdio.h>

void splitString(char ** arr,char * source,int & count){
count = 0;

char *s =NULL;

s=strtok(source," ");
printf("s= %s\n",s);
while(s != NULL)
{
*arr++ = s;
count ++;
s = strtok(NULL," ");
}
}

void main(){
char * arra[30];
char str[100] = "i love you";
int count = 0;

splitString(arra,str,count);

for(int i =0;i<count;i++)
printf("%s\n",arra[i]);

printf("\n");

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: