Originally Posted by
Ali.B
yes i understood this part... and I can use it now... thanks for the sample code
the output will be this; since my variables are xcoord and ycoord;
0050011611
now how can i add other characters to this string? and make it look like this:
X=00500Y=11611
X,= and Y should be added to the string.. how can i handle this?
nvm... i figured it out by playing the peice of code u Dino gave me
i did like this:
Code:
int main()
{
char Text[80] = {0};
char * line = "GET /send.htm?Text=START+00500+11611 HTTP/1.1";
char *s,*t;
char bt_msg[20] = {0};
if(s = strchr(line, '+'))
{
if(t = strchr(s, ' '))
strncpy(Text, s+1, t-s);
}
char *xcoord=strtok(Text,"+"), *ycoord=strtok(NULL,"+");
printf("x-coord:%s\n", xcoord);
printf("y-coord:%s\n", ycoord);
strcat(bt_msg, "X=");
strcat(bt_msg, xcoord);
strcat(bt_msg, "Y=");
strcat(bt_msg, ycoord);
printf("bt_msg= %s\n", bt_msg) ;
}
and the output is as i wanted:
Code:
bt_msg= X=00500Y=11611
thanks Dino for ur help