c语言实现字符串分割

c语言简单分割字符串:

#include<stdio.h>
#include<string.h>
int main(){
  char oldstr[]="hahaha:hehehe-xixixi heiheihei";
  char *newstr="";
  char *splitstr=":- ";
  newstr = strtok(oldstr,splitstr);
  while(newstr !=NULL){
    printf("%s\n",newstr);
    newstr = strtok(NULL,splitstr);
  }
  return 0;
}


你可能感兴趣的:(c语言实现字符串分割)