Thread: Concat a Char to String.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2008
    Location
    Santa Catarina - Brasil
    Posts
    184
    Code:
    void EnviaPedidoPC (unsigned char *pMsg){
    	
    	unsigned char cFinal [3];
    	unsigned char *cMsgFinal;
    	int iLen;
    	
    	if (iUserSocket){
    
    		cMsgFinal [0] = cSTX;
    		strcat (cMsgFinal, pMsg);
    		cFinal [0] = cCR;
    		cFinal [1] = cLF;
    		cFinal [2] = '\0';
    		strcat (cMsgFinal, cFinal);
    		
    		iLen = strlen (cMsgFinal);
    		
    		VcomSendSocket(iUserSocket, cMsgFinal, iLen);	
    	}
    }

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    cMsgFinal still points to "nowhere in partciular", which is not a good place to store things.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  2. Sorting Linked Lists
    By DKING89 in forum C Programming
    Replies: 6
    Last Post: 04-09-2008, 07:36 AM
  3. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  4. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 03:58 PM
  5. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM