Trying to copy a char *str
to char c[]
but getting segmentation fault or invalid initializer error.
Why is this code is giving me a seg fault?
char *token = "some random string";
char c[80];
strcpy( c, token);
strncpy(c, token, sizeof c - 1);
c[79] = '';
char *broken = strtok(c, "#");
See Question&Answers more detail:os