Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char *command = "nest";
- char *halloween = join("hallowee", command[0]); //this gives an error
- char *join(const char* s1, const char* s2)
- {
- char* result = malloc(strlen(s1) + strlen(s2) + 1);
- if (result)
- {
- strcpy(result, s1);
- strcat(result, s2);
- }
- return result;
- }
- char *join(const char* s1, const char c)
- {
- int len = strlen(s1);
- char* result = malloc(len + 2);
- if (result)
- {
- strcpy(result, s1);
- result[len] = c; //add the extra character
- result[len+1] = '