Having this:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (void) {
char *str = "foo\n"; //if 'char str[] = "foo\n";' no problem
char *c = strchr(str, '\n');
*c='\0'; //causes "command terminated"
// *(c+0)='c' does not help
return 0;
}
I have no idea, why program crash, when I got c
pointer from strchr
and then dereference it in assignment.