-
-
Save briankip/afc126f8000c94c818b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() | |
{ | |
char *str = "blablabla"; | |
char c = 'H'; | |
size_t len = strlen(str); | |
char *str2 = malloc(len + 1 + 1 ); /* one for extra char, one for trailing zero */ | |
strcpy(str2, str); | |
str2[len] = c; | |
str2[len + 1] = '\0'; | |
printf( "%s\n", str2 ); /* prints "blablablaH" */ | |
free( str2 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment