Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This was a small little project I made for fun working with files.
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <stdlib.h>
- using namespace std;
- string username;
- string password;
- void inFunc();
- int main()
- {
- ofstream file_write("c++text.txt");
- cout << "Type in \"lol\" to get your username and password or register by typing in a username: ";
- cin >> username;
- cout << "Password: ";
- cin >> password;
- file_write << username << ", " << password << endl;
- system("pause");
- int choice;
- cout << "Type in 5 for your username and password: ";
- cin >> choice;
- if(choice == 5)
- {
- inFunc();
- }
- else
- {
- cout << "An error has occurred!" << endl;
- }
- }
- void inFunc()
- {
- ifstream file_read("c++text.txt");
- while(file_read >> username >> password) //Scan in file for the variables while they exist.
- {
- cout << username << ", " << password << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment