hello guys...
I need to split the following string and save each part as a separate variable.
there string always will have 5 digits, a Plus (+) sign in the middle and 5 digits on the other side. so its always following the same structure.
i want to save "00500" as char xcoord, and "00611" as char ycoord. how would i do that? i tired strtok() but i could only extract one digit, here's my code:
Code:
int main()
{
char Text[80] = {0};
char * line = "GET /send.htm?Text=START+00500+11611 HTTP/1.1";
char *s,*t;
char * xcoord;
char * ycoord;
if(s = strchr(line, '+'))
{
if(t = strchr(s, ' '))
strncpy(Text, s+1, t-s);
}
// at this point Text will be 00500+11611
//xcoord = strtok (Text, "+");
printf("%s\n", xcoord);
//at this point xcoord will be 00500
printf("%s\n", Text);
}
thanking you in advance