I have been looking around the internet and SO, and am trying to find how to detect and fix segfaults. I tend to get this error a lot, and all I could find on google and SO was it is a memory issue(This answer helped a lot: https://stackoverflow.com/a/3200536/3334282). I want to know what the poor programming is that causes it so that I can avoid it.
My most recent example was trying to learn how to use fgets().
FILE *text;
char array[100];
fopen("text.txt", "r");
fgets(array, 100, text);
printf("%s\n", array);
fclose(text);
This returns 8181 segmentation fault (core dumped).