How do I append a single char to a string in C?
i.e
char* str = "blablabla"; char c = 'H'; str_append(str,c); /* blablablaH */
char* str = "blablabla";
You should not modify this string at all. It resides in implementation defined read only region. Modifying it causes Undefined Behavior.
You need a char array not a string literal.
Good Read: What is the difference between char a[] = "string"; and char *p = "string";
1.4m articles
1.4m replys
5 comments
57.0k users