Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
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
0
Please
log in
to post a comment.
Herout (67) - 3
Herout (67) - 8
lab7_OOP 0.2 beta
Linked list: Traverse and insert
resize.c
Vectores: mayor, menor, media
Use of Arithmetic Operator
CV09-2.1
cv2
random()%N stddev
Please log in to post a comment.