ERROR BRACE
Aug 7, 2014 at 6:15am UTC
i have a missing left brace but i cannot find ..
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
#include <conio.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
class User
{
public :
string username;
string password;
void userRegister()
{
cout << "\n---------Registration Screen--------" << endl;
cout << "Enter Username: " ;
cin >> username;
cout << "Enter Password: " ;
cin >> password;
fstream usersFile;
usersFile.open("userID.txt" , fstream::app);
if ( !usersFile.is_open())
{
cout << "Unable to open file!" << endl;
}
else
{
usersFile << username << " " << password << endl;
}
usersFile.close();
};
int main()
{
int choice;
cout << "Welcome to THE GAME OF LIFE!!!11" << endl;
cout << "1. Register" << endl;
cout << "2. Login" << endl;
cout << "Your choice is: " ;
cin >> choice;
if (choice == 1)
{
User person;
person.userRegister();
}
else if (choice == 2)
{
string userID, password;
string pwdId, pwd;
bool found = false ;
int i = 0;
cout << "\n----------------Login Screen--------------------" << endl;
}
while (i(heart) && !found)
{
cout << "Please enter your userID:\t" ;
cin >> userID;
cout << "Please enter your password:\t" ;
cin >> password;
ifstream inFile;
inFile.open("userID.txt" );
found = false ;
if (!inFile)
cout << "Unable to open file" << endl;
else
{
while (!inFile.eof() && !found)
{
inFile >> pwdId >> pwd;
if (userID.compare(pwdId) == 0 &&
password.compare(pwd) == 0)
{
found = true ;
cout << "Welcome! \n" ;
}
if (!found)
{
i++;
cout << "You have entered the wrong info!" << endl;
}
else
{
cout << "You have successfully logged into the system!" << endl;
}
}
if (i==3)
cout << "\nYou have reached maximum number of trials. Access Denied!" << endl;
system("pause" );
return 0;
}
else
{
cout << "Error! Choice invalid!" << endl;
}
system("pause" );
return 0;
}
Aug 7, 2014 at 6:22am UTC
After line 33 you are missing a '}' You would notice a lot easier if you actually indented with tabs instead of spaces.
Aug 7, 2014 at 11:23am UTC
he's right ^
Aug 7, 2014 at 11:56am UTC
I'd suggest using an editor such as Notepad++ which can highlight matching braces and simplifies this sort of issue. (Other editors can do this too).
http://notepad-plus-plus.org/
Aug 8, 2014 at 1:06pm UTC
@Chervil code blocks latest will do too... anyways how can i compile c++ in notepad i can only use html
Aug 8, 2014 at 2:02pm UTC
Topic archived. No new replies allowed.