Advertisement
Guest User

Untitled

a guest
Mar 29th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <stdlib.h>
  4. #include <fstream>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. void mainmenu();
  10.  
  11.  
  12. int choice;
  13. bool cinfail;
  14. int confirmation;
  15. string username, password, password2;
  16.  
  17. void writetofile(string username){
  18. ofstream writefile;
  19. string file = username+".txt";
  20. writefile.open(file.c_str());
  21. writefile << password;
  22. writefile.close();
  23. mainmenu(); }
  24.  
  25. void login(){
  26. cout << "You are being logged in!";}
  27.  
  28.  
  29. void registerpassword(){
  30. cout << "Please enter the password:" << endl;
  31. cin >> password;
  32. cout << "Please renter your password:" << endl;
  33. cin >> password2;
  34. if (password == password2){
  35. cin.clear();
  36. cin.ignore(10000,'n');
  37. writetofile(username);
  38. exit(1);
  39. }
  40. else;{
  41. cout << "Sorry invalid" << endl;
  42. registerpassword();
  43. }}
  44.  
  45.  
  46. void registerme(){
  47. cout << "Please enter your username: " << endl;
  48. getline(cin, username);
  49. cout << "nUsername - ""<< username << ""nConfirm? nn[1] Yesn[2] No" << endl;
  50. cin >> confirmation;
  51. if (confirmation == 1){
  52. registerpassword();
  53. }
  54.  
  55. else; {
  56. cout << "Sorry invalid input, Please try again" << endl;
  57. cin.clear();
  58. cin.ignore(10000,'n');
  59. registerme();
  60. }}
  61.  
  62.  
  63. void exit(){
  64. exit(0);}
  65.  
  66. void mainmenu(){ cout << "Hello, Would you like to log in or registern[1] Loginn[2] Registern[3] Exit" <<endl; cin >> choice; do{
  67. cinfail = cin.fail();
  68. cin.clear();
  69. cin.ignore(10000,'n');
  70.  
  71. }while(cinfail == true);{
  72. switch(choice){
  73. case 1:
  74. login();
  75. break;
  76.  
  77. case 2:
  78. registerme();
  79. break;
  80.  
  81. case 3:
  82. exit();}}}
  83.  
  84. main(){
  85. mainmenu();
  86. }
  87.  
  88. int main()
  89. {
  90. Foo();
  91. if (TheSkyIsBlue)
  92. {
  93. Bar();
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement