output data from dat file to memory

Hid_Enigma

In Runtime
Messages
154
I am looking to compare a username and password that a user sets in the beginning of a program and save it. When the user reopens the program again at a later date, I would like to be able to have the user reinput the username and password and have it verified from the saved file. I am able to have the user input the data to a dat file but cannot retrieve the information from the file to verify it. Any suggestions.
 
What you are trying to do has a lot of solutions. Could you provide more information about your application?

What language are you writing it in?

Also, this doesn't seem very secure, why not use a database?
 
Sorry using C++ as far as a database right now i am not to familiar with using databases. What i need to store is just a user and pass on the local machine. What the program will need to do is have the user input the user and pass they would want to use to run the program. then once the user and pass is inputted I was thinking about using a small if else statement to check the user and pass with the one stored in the file. if they match then the program runs if they dont it says invalid user and pass. Then the program gives them an option to try again or to end. Now this program really doesn't need to have a username and password but want to get practice on using the code to do this.
Thanks in advance
 
I see. In the future, when you have a better handle on databases and encrypting user information, I suggest you do it that way. I am a bit rusty on my c++, there are many on this forum much more well versed than I am. Here is a link to an article that talks about File I/O processes in c++.
http://www.cplusplus.com/doc/tutorial/files.html

In their example, they output whatever is found in the text file to the screen. Instead, you could format the text file on two lines and have the username on the first and the password on the second, and read the two lines into two separate variables then compare those values against what the user input. Hope this is helpful, please ask for clarification on anything I didn't make clear.
 
Back
Top Bottom