Search code examples
cstructaccount

Storing data in a struct or txt file?


Im making an mock ATM program for practice and was wondering is it better to

  1. store someones account information in a struct on another file and have each users information on that
  2. Have it all in a txt file and just read it while making an algorithm to grab what you need based on pin location ?

right now iv just made a pin list in a text file which counts and stores the data into an array which i check which then opens an account based on that user input ect ect.

i can see both working but was just wondering whats the proper process for stuff such as this ?


Solution

  • It may depend on your operating system and the language/development tools you use as some will have libraries allowing easy access to structured data in a standardized format as pointed out above. Text files are rarely the way to go long term since you will have to write all the code yourself, not only creating a lot of work but opening yourself to bugs and potential security issues. If you can use a library, a lot of that work is already done for you.