1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<fstream>
#include<conio.h>
using namespace std;
void title()
{
cout<<"_________________________"
<<"\n GamerNet v2.0 "
<<"\n-------------------------";
}
int main(int nNumberofArgs, char* pszArgs[])
{
int ans, tries;
tries = 0;
string newUser, newPass, goodUser, goodPass, _pass, _user;
string pass2, user2;
start:
{
system("cls"); //Clears the Screen
title();
cout<<"What would you like to do?"
<<"\n1>Register for an Account"
<<"\n2>Log in"
<<"\n3>Exit GamerNet" << endl;
cin>>ans;
cin.clear();
while (cin.get()!='\n');
if (ans == 3) goto end;
if (ans == 2) goto login;
if (ans == 1) goto reg;
goto start;
}
reg:
{
system("cls");
cout<<"Enter New Username: ";
getline(cin,newUser);
cout<<"Enter New Password: ";
getline(cin,newPass);
//Write User Info to File
ofstream new_data("Reg_Data.txt");
new_data <<"Username: " << newUser
<<"\nPassword: " << newPass;
new_data.close();
//Inform the User of Registration Success
system("cls");
cout<<"Welcome, " <<newUser <<" to GamerNet (v2.0)!"
<<"\n>Here, you'll find the latest news of the gaming world!";
system("pause");
goto start;
}
login:
{
system("cls");
cout<<"Enter Username: ";
getline(cin,goodUser);
cout<<"Enter Password: ";
getline(cin,goodPass);
//Read Data from Text File
ifstream new2_data;
new2_data.open("Reg_Data.txt");
//char output[100];
if (new2_data.is_open())
{
new2_data.ignore(10); //ignoring "Username: "
getline(new2_data,_user);
new2_data.ignore(10); //ignoring "Password: "
getline(new2_data,_pass);
}
new2_data.close();
system("cls");
//Verify Data from Text File
if (goodUser == _user and goodPass == _pass)
{
cout<<"Login Successful! Please enjoy our services!\n";
system("pause");
goto normal;
}
else
{
if (tries < 3)
{
cout<<"Invalid Login! Please try again.\n";
system("pause");
tries++;
goto login;
}
else
{
cout<<"Invalid Login!\n";
system("pause");
goto end;
}
}
}
//Default Stop for All GamerNet (v2.0) Users
normal:
{
system("cls");
cout<<"Latest News: Miyamoto has released the NEW Super Mario Bros. Wii!"
<<"\nThe game has already brought in millions for Nintendo.\n";
system("pause");
}
end:
{
system("cls");
cout<<"Exiting System...\n";
system("pause");
return 0;
}
}
|