Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting the error [Error] expected unqualified-id before ')' token
on line 18 when i try to run the code.
#include <iostream>
#include <string>

using namespace std;
int n,un,pin;
//registration variables
string fname, lname,r_un,rpw,rrpw;
//login variables,
string l_un,lpw;
 showmenu()
{
	cout <<"Welcome to MCB Bank \n\nPress 1 to Register your account or 2 for login\n";
	
	cin>>n;
		
}
 register ()
{
	int count=0;
	cout <<"Welcome! Please enter your first name\n";
	cin>>fname;
		cout <<"Please enter your second name\n";
	cin>>lname;
		cout <<"Please enter your username\n";
	cin>>r_un;
		cout <<"Select a Password\n";
	cin>>rpw;
		
	while (count<1)
	{
		cout <<"Repeat Password\n";
		cin>>rrpw;
		if (rrpw==rpw)
		{
		
		count++;
		}
	}
	cout <<"Enter a security pin\n. This will be used when your perform your transactions";
	cin>>pin;
}
login()
{
	cout <<"Enter your username\n";
	cin>>l_un;
	cout<<"Enter your password";
	cin>>lpw;
}
forgotpassword()
{
	
}
int main()
{
	showmenu();
	
	
	
}


What I have tried:

I tried declaring function with data type string but still get same error
Posted
Updated 15-Jan-22 1:31am
v2

1 solution

Change register() function name to Register(). register is a C/C++ reserved keyword.


You missing semicolon.
The line:
C++
int count=0
cout <<"Welcome! Please enter your first name\n";


should be:
C++
int count=0;
cout <<"Welcome! Please enter your first name\n";


And all your functions should have void as return value:

C++
void showmenu()
void Register ()
void login()
void forgotpassword()
 
Share this answer
 
v4
Comments
Hamza Jameel 15-Jan-22 7:32am    
I fixed it but still getting same error.
updated the code
steveb 15-Jan-22 7:43am    
Change register() to Register(). register is a reserved C/C++ keyword and as such cannot be used as function or variable names
Hamza Jameel 15-Jan-22 7:45am    
It worked perfectly thanks!
CPallini 15-Jan-22 16:03pm    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900