daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Jun 18th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. #define VERSION "1.0"
  6. #define AUTHOR "Melvin Koopmans"
  7.  
  8. using namespace std;
  9.  
  10. string username;
  11. string password;
  12. string line;
  13. int option;
  14. char back;
  15.  
  16.  
  17. int loginform()
  18. {
  19.     cout << "Login" << endl;
  20.     cout << "Username: ";
  21.     getline (cin, username);
  22.     cout << "Password: ";
  23.     getline (cin, password);
  24.     ifstream datafile (username+".txt");
  25.     if (datafile.is_open())
  26.     {
  27.     while (! datafile.eof() )
  28.     {
  29.       getline (datafile,line);
  30.       if ( line==password )
  31.       {
  32.           cout << "Welcome " << username << "!" << endl;
  33.       }
  34.       else
  35.       {
  36.           cout << "Invalid login!" << endl;
  37.       }
  38.     }
  39.     datafile.close();
  40.     }
  41.     return 0;
  42. }
  43.  
  44. int registerform()
  45. {
  46.     cout << "Register" << endl;
  47.     cout << "Username: ";
  48.     getline (cin, username);
  49.  
  50.     cout << "Password: ";
  51.     getline (cin, password);
  52.     ofstream datafile;
  53.     datafile.open (username+".txt");
  54.     datafile << password;
  55.     datafile.close();
  56.     cout << "Registed Succesfuly!" << endl;
  57.     return 0;
  58. }
  59.  
  60. int main()
  61. {
  62.     start:
  63.     cout << "MyProgram " << VERSION << endl;
  64.     cout << "1. Login" << endl;
  65.     cout << "2. Register" << endl;
  66.     cout << "3. Credits" << endl;
  67.     cout << "4. Exit" << endl;
  68.     cout << "Choose an option: ";
  69.     cin >> option;
  70.    
  71.     if ( option == 1 )
  72.     {
  73.         loginform();
  74.     }
  75.     else if ( option == 2 )
  76.     {
  77.         registerform();
  78.     }
  79.     else if ( option == 3 )
  80.     {
  81.         cout << "Made by: Melvin Koopmans" << endl;
  82.         cout << "Made in C++ " << endl;
  83.         cout << " " << endl;
  84.         back2:
  85.         cout << "Back[y/n]?: ";
  86.         cin >> back;
  87.  
  88.         if ( back == 'y' )
  89.         {
  90.             goto start;
  91.         }
  92.         else if ( back == 'n' )
  93.         {
  94.            
  95.         }
  96.         else
  97.         {
  98.             cout << "Invalid option!" << endl;
  99.             goto back2;
  100.         }
  101.     }
  102.  
  103.     else if ( option == 4 )
  104.     {
  105.        
  106.     }
  107. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top