split string...

I'd like to get some text from a string.

Source Code :
char str[] = "@KEC:80:DET:90:";
char *test[sizeof(strtok(str, ":"))];
if(sizeof(test) > 0)
{
test[0] = strtok(str, ":");
printf ("%s\n",test[0]);
for(int k = 1; k < sizeof(strtok(str, ":")); k++)
{
test[k] = strtok (NULL, ":");
printf ("%s\n",test[k]); }
}

Output :
@KEC
80
DET
90

But, i want to save each numeric data to variable...
example :
data1=80;
data2=90;

Thanks for the help... Thanks before...
Topic archived. No new replies allowed.