Anoying errror
Nov 20, 2012 at 4:40pm UTC
So here's the deal. I was a making a simple program. Register, Login and Exit but I wanted the password to show up as "*" so I came here and I found a solution but now it gives me an error that I cannot solve.
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
#include <iostream>
#include <string>
#include <stdlib.h>
#include <conio.h>
using namespace std;
string user, pass, pass1, user1;
int main()
{
string menu, again, admin;
do {
cout << "options \n" ;
cout << "register (reg)\n" ;
cout << "login (log)\n" ;
cout << "exit (exit)\n" ;
cin >> menu;
if ( menu == "reg" ){
string admin ="" ;
char ch;
cout << "administrator password" ;
ch = _getch();
while (ch != 13){//character 13 is enter
admin.push_back(ch);
cout << '*' ;
ch = _getch();
}
if ( admin == "jonhy31" ){
cout << "desired username\n" ;
cin >> user;
}
}
}
}
The error is : " error C2059: syntax error : '}' "
P.S.:I use Microsoft Visual C++ 2010 Express Edition
EDIT: The program is not finished because I was trying it on.
Last edited on Nov 20, 2012 at 4:41pm UTC
Nov 20, 2012 at 4:45pm UTC
you're missing the while portion of the do loop.
the syntax is
1 2 3 4 5
do
{
//your code here
}
while (boolean expression);
Nov 20, 2012 at 4:48pm UTC
Thank you. I guess with all the hurry of trying it on I forgot it.
Topic archived. No new replies allowed.