Append Char To String in C?

c, string

Solution

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";

Problem

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 */ ```

Original source

Related problems