English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

#include
#include

int main ()
{
char num[] ="1.00:2.00:3.00";
char *ch;
char r[100];
printf ("split \"%s\":\n",num);
ch = strtok (num,":");
while (ch != NULL)
{
i = 0;
printf ("%s\n",ch);
ch = &r[i];
ch = strtok (NULL, ":");
i ++;
}
return 0;
}


--> here is my strtok code, but it doesn't work.

how can i copy the values of the pointer ch into a char array r? thanks.

2007-03-22 02:02:28 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

1 answers

1. need to add "int i = 0;" at the top and remove "i = 0;".
2. the printf is working fine.
3. strcpy(&r[i],ch); i += strlen(ch) + 1; instead of the last 3 lines in the llop

2007-03-22 03:05:46 · answer #1 · answered by eyal b 4 · 0 0

fedest.com, questions and answers