I'm doing my assignment. I want to start after I retrieve the data and variables that I had before I started. So we start fopen in read format first, then we move on to the menu window. But the problem is that the files are saved when the program exits, so if you don't run them once, there's no saved file. So I keep getting errors when I run it for the first time, what should I do?
file-io
When you open a file with fopen, if the error code appears to be "no file", then you can initialize the variables right away on the memory and start.
Check for files
File is present:
Initialize data by reading previous data values
File does not exist:
Initialize data with default data values
© 2024 OneMinuteCode. All rights reserved.