12
char* str1; char* str2;
123456789101112131415
char* XPortMsg(char* inmsg) { char* mHeader = "DLL Received: "; // retrieve incoming string and assign to variable char* msgHeader = new char[strlen(inmsg)+1]; memcpy(msgHeader,inmsg,strlen(inmsg)+1); char* retVal = new char[strlen(mHeader)+strlen(msgHeader)+1]; // Assemble the string strcat(retVal,mHeader); strcat(retVal,msgHeader); return retVal; }
123
// Assemble the string strcpy(retVal,mHeader); strcat(retVal,msgHeader);
1234567891011121314151617
char* XPortMsg(char* inmsg) { char* mHeader = "DLL Received: "; // retrieve incoming string and assign to variable char* msgHeader = new char[strlen(inmsg)+1]; memcpy(msgHeader,inmsg,strlen(inmsg)+1); msgHeader[strlen( inmsg )] = '\0'; char* retVal = new char[strlen(mHeader)+strlen(msgHeader)+1]; *retVal = '\0'; // Assemble the string strcat(retVal,mHeader); strcat(retVal,msgHeader); return retVal; }
*retVal = '\0';