Felanpro

small project

May 11th, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. //This was a small little project I made for fun working with files.
  2.  
  3. #include <iostream>
  4. #include <fstream>
  5. #include <string>
  6. #include <stdlib.h>
  7.  
  8. using namespace std;
  9.  
  10. string username;
  11. string password;
  12.  
  13. void inFunc();
  14.  
  15. int main()
  16. {
  17.     ofstream file_write("c++text.txt");
  18.  
  19.     cout << "Type in \"lol\" to get your username and password or register by typing in a username: ";
  20.     cin >> username;
  21.  
  22.     cout << "Password: ";
  23.     cin >> password;
  24.  
  25.     file_write << username << ", " << password << endl;
  26.  
  27.     system("pause");
  28.  
  29.     int choice;
  30.  
  31.     cout << "Type in 5 for your username and password: ";
  32.     cin >> choice;
  33.  
  34.     if(choice == 5)
  35.     {
  36.         inFunc();
  37.     }
  38.     else
  39.     {
  40.         cout << "An error has occurred!" << endl;
  41.     }
  42.  
  43. }
  44.  
  45. void inFunc()
  46. {
  47.     ifstream file_read("c++text.txt");
  48.  
  49.     while(file_read >> username >> password) //Scan in file for the variables while they exist.
  50.     {
  51.         cout << username << ", " << password << endl;
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment