Mutable strings:
You are passing it a pointer to a string which you're not allowed to modify (you can't modify literal strings). That could be the cause of the segfault. So instead of using a pointer to the non-modifiable string literal, you could copy it to your own, modifiable buffer, like this:
char mybaz[] = "hello:world";
Immutable strings:
if you passing it a pointer to a string which you're not allowed to modify (you can't modify literal strings). That could be the cause of the segfault.
char *mybaz = "hello:world";
Reference:
https://stackoverflow.com/questions/1863094/pass-strings-by-reference-in-c
No comments:
Post a Comment