Run Code
|
API
|
Code Wall
|
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
Bucles: Ver si un número es primo
salida
Herout (67) - 8
Es un rectangulo
life
Vectores: Vector inicializado manualmente
Ashar
lab4.1 C
random()%N stddev
Herout (67) - 5