int main(){
char str[] = "class=first,age=adult,gender=male,survived=no";
char delims[] = ",=";
char *result = NULL;
result = strtok( str, delims );
char array[200];
int num=0;
while( result != NULL ) {
printf( "result is \"%s\"\n", result );
result = strtok( NULL, delims );
} ;
}
这个代码能把东西都分割好了。但是加不进数组
把class first age adult gender male survived no 加进数组?array[0] array[1] array[2].....
char str[] = "class=first,age=adult,gender=male,survived=no";
char delims[] = ",=";
char *result = NULL;
result = strtok( str, delims );
char array[200];
int num=0;
while( result != NULL ) {
printf( "result is \"%s\"\n", result );
result = strtok( NULL, delims );
} ;
}
这个代码能把东西都分割好了。但是加不进数组
把class first age adult gender male survived no 加进数组?array[0] array[1] array[2].....