A very simple C program: I want to put 0's at some points in a string to obtain sub-strings. But at the first try I get segmentation fault on execution:
#include<stdio.h>
#include<string.h>
int main() {
char *a = "eens kijken of we deze string kunnen splitten";
a[4] = '\0'; // this causes the segfault
char *b = a[5]; // sort of guessed this can't work...
printf("%s", a);
}
So the main question: why the segfault at a[4] = '\0';
Second I'd like to split this string with the least amount of code, based on string-index...