Thread: make one string from 2 strings.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    39

    Post make one string from 2 strings.

    hello
    i managed to parse the parts that i need from this string:
    Code:
    "GET /send.htm?Text=START+00500+11611 HTTP/1.1"
    with this pair of code ( with help of this forum ):
    Code:
    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);
    }
    so basically:
    the output will be:
    Code:
    x-coord: 00500
    y-coord: 11611
    i need to assemble a payload that follows the following structure:
    Code:
    "X=00500Y=11611"
    than means the first five digits represent the x-coord and the 2nd five digits represent y-coord.
    i need to save assemble this payload from those coordinates and put in a variable so i can use it later on.may be save it as bt_msg. how could i do it?
    thanks
    Last edited by Ali.B; 08-12-2009 at 04:30 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  2. Help! Homework using Strings
    By wco5002 in forum C++ Programming
    Replies: 16
    Last Post: 09-27-2007, 03:53 AM
  3. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. "Operator must be a member function..." (Error)
    By Magos in forum C++ Programming
    Replies: 16
    Last Post: 10-28-2002, 02:54 PM

Tags for this Thread