How do I concatenate Strings with C/C++?
I tried the following ways:
PS: errorInfo is a char * I should return it.
errorInfo = strcat("Workflow: ", strcat(
workflowToString(workflow).utf8(), strcat(" ERROR: ",
errorCode.utf8)));
sprintf(errorInfo, "Workflow %s ERROR: %s",
workflowToString(workflow).utf8(), errorCode.utf8());
errorInfo = "Workflow: " + workflowToString(workflow).utf8() + " ERROR: " + errorCode.utf8;
Just the sprintf compiles but when running my application crash.
PS: I’m using NDK from Android
According to this page
strcatdoes the following:In your implementation, however,
"Workflow: "is a constant string. You cannot modify that string, which is whatstrcatwould do. In order to do that, create a string like:However, be careful about the utf8 character encoding because one utf8 code point could be multiple
chars long.