int strings(void){
int NumStrings = 3;
char **strings = (char**) malloc(sizeof(char*) * NumStrings);
int i;
char * element = "Trevor";
for(i = 0; i < NumStrings; i++){
strings[i] = ((char*) malloc(sizeof(char) * strlen(element)+1));
}
strings[0] = "abcdef";
strings[1] = "lemons";
strings[2] = "zoozoo13333";
for(i = 0; i < NumStrings; i++){
printf("%s\n", strings[i]);
}
}
Why is this not causing a seg fault? I haven't allocated enough memory for "zoozoo13333", but it still prints fine, and doesn't throw any errors. Shouldn't there only be enough room in the array for a string that is 6 characters long?