I want to transform
string s="aaa,bbb,ccc"
into:
char * a[]={"aaa", "bbb", "ccc"}
Could you help me how to program for dealing with this process?
I will try to program like this:
string s="aaa,bbb,ccc";
char * a[];
char id[] = "";
strcpy(id, s.c_str());
const char * split = ",";
char * p;
p = strtok(id, split);
while (p != NULL) {
int i = 0;
printf("%s\n", p);
a[i]=p;
i++;
p = strtok(NULL, split);
}
where is my wrong? who can point out ?