I wrote the following C program:
int main(int argc, char** argv) {
char* str1;
char* str2;
str1 = \"sssss\";
str2 = \"kkkk\";
printf(\"%
The way it works is to:
free (str3);Here's an example for you play with. It's very simple and has no hard-coded lengths. You can try it here: http://ideone.com/d3g1xs
See this post for information about size of char
#include
#include
int main(int argc, char** argv) {
char* str1;
char* str2;
str1 = "sssss";
str2 = "kkkk";
char * str3 = (char *) malloc(1 + strlen(str1)+ strlen(str2) );
strcpy(str3, str1);
strcat(str3, str2);
printf("%s", str3);
return 0;
}