As Avilius suggested, I will not write the whole program for you to use.
I assume that you have no code or very little code. Again as Avilius suggested, fstream would be a very useful tool for a program like this as you can then remember previous names from other run times of said program. As a recommendation from me, I would say look into arrays, in particular one that has two dimensions, one for the users name and the other for their password. That will help with matching users to their passwords and checking to see if they match.
std::map or std::unordered_map might be a good option to look into.
When registering, you'd just have to do something like
1 2 3 4 5
// Assuming 'userPasswords' is a std::map<std::string, std::string>
if (userPasswords.count(newUsername) > 0) // If user already exists
// Yada yada, this user already exists, etc.
else
userPasswords[newUsername] = newPassword;
and for logging, it'll be something like
1 2 3 4 5 6
if (userPasswords.count(username) == 0) // If user doesn't exist
// Deal with nonexistant user here
elseif (userPasswords[username] != password)
// Wrong username/password combination
else
// Logged in, yay.
You'll have to save it to a text file and load it up again next time if you want the program to "remember".
If you disallow spaces in the username or password, you could simply just do
(Obviously, that's not a very secure way of saving it, but that's just an example of one way you could do it.)
I was going to post old code I had that used Sockets and MySQL (using the MySQL++ wrapper) to connect to a database on my old website, but this would be overwhelming due to throwing sockets, C++, and MySQL at him. It was a project I was doing for a game I scrapped (mainly because I took down the site) for usernames and high scores to see who was doing good out of the players. I think yours is way simpler though.