So, I’m making a game and it has a function called “createWindowAndInit” which initializes the SDL libraries and creates the window and renderer. This function also gets the information of the save data file and this is where the segmentation fault arises. After using GDB and valgrind I discovered what the error is and after a little testing discovered the general area where it is. So, it happens in both of the for loops inside of the function because if you remove both it’s fine.
This is the function where it occurs: int createWindowAndInit(){ if(SDL_Init(SDL_INIT_EVERYTHING) != 0){return SDL - Pastebin.com
And this is the whole code which you should not read entirely because if you do you will go insane: // Compile with: g++ main.cpp -lSDL2 -lSDL2_image -lSDL2_ttf -o "Five Nights At - Pastebin.com