I'm testing out a game mechanic where there will be two files (one called 'X.txt' and the other 'Y.txt') that keep track of your X and Y position. The way it works is that everytime an update for the player is called (i.e movement), the program will write the coordinates to the X and Y file. And when you close the program and reopen that file, you will start off at the X and Y coordinates that you were at when you last closed the program. I have two problems:
1) Everytime time I run the program I start at the default coordinates (0, 0) even though I'm telling the program to read from the file.
2) When I close the program I get an error saying :
'Unhandled exception at 0x576812A7 (msvcp120d.dll) in FNTSTWE.exe: 0xC0000005: Access violation reading location 0xFEEEFEEE.'
The error are variable by the way, they are always quite different, this is just one of the many errors I got.
Also, sometimes it leads me to different files like 'xlocale' or 'output.c'.
I think these two things are linked and if I can fix them I can get them both to work.
Here is the code : https://www.dropbox.com/s/j56kb41q3bmmnby/Program_SDL2_IO_Error.zip?dl=0
Just look at the code and please tell me what I'm doing wrong.
In order to recreate the errors I was talking about, use the files to create a Visual Studio SDL2 project and debug it to see what I mean.
Please Help.
Thank you.