Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
C - Append Character to String
#include <stdio.h> #include <string.h> int main(int argc, char **argv) { // Define a string. char *str = malloc(4 * sizeof(char)); strcpy(str, "Hild"); // Define a char, and convert it to a string. char c = 'a'; char *cStr = malloc(sizeof(char)); *cStr = c; // Append one character to a string. size_t len = strlen(str); str = realloc(str, len + sizeof(char)); strcat(str, cStr); printf("My name is %s.\n", str); // Free memory. free(cStr); free(str); return 0; }
run
|
edit
|
history
|
help
1
Please
log in
to post a comment.
Herout (67) - 5
lab7_OOP 0.2
fun kce
Bucles: Euclides
Bucles: secuencia ascendente de números
Punteros: dame tres valores
Euclides 2
pointer
Celcius to Farenheir,Romer,Kelvin
Comprueba si orden creciente
Please log in to post a comment.