| madhatt30 (13) | |||
I have two arrays defined as follows
what I want to do is to combine these two into one for example str3 | |||
|
|
|||
| madhatt30 (13) | |||
|
ok got it almost working but it returns the following in my program h7öÄDLL Received Calling DLL everything is correct but the very beginning "h7öÄ" what could be causing this. The following is the code
| |||
|
|
|||
| vlad from moscow (3112) | |
|
After that statement char* retVal = new char[strlen(mHeader)+strlen(msgHeader)+1]; write *retVal = '\0'; Also after memcpy(msgHeader,inmsg,strlen(inmsg)+1); write msgHeader[strlen( inmsg )] = '\0'; | |
|
Last edited on
|
|
| kbw (5375) | |||
| |||
|
|
|||
| madhatt30 (13) | |||
That did it vlad thanks so much. I've included the complete code in case anyone else searches for this and needs it.
also could you briefly explain to me what *retVal ='\0'; is doing it looks like it is appending a '\0' but i'm confused about what the *retVal does. or a nice link to a good explanation would be even better :) thanks again | |||
|
|
|||
| kbw (5375) | |||
|
new char ... returns an uninitialsed block of memory. A string is null terminated, but your retVal thing is uninitialised. You can make it into a string by making it null terminated with
or by just copying the string in with strcpy instead of concatinating the string with strcat. | |||
|
|
|||