segmentation fault with strcpy [duplicate]
You haven’t initialized *str_new so it is just copying str_old to some random address. You need to do either this: or You will have to #include <stdlib.h> if you haven’t already when using the malloc function.