error C1004: unexpected end-of-file found & '{' : missing function header (old-style formal list?)

#include <iostream>
#include <string>
using namespace std;

{
int counter=0;
string Username;
string Password;
string InvalidUser;
int opt;


system("cls");
cout <<"\n\n";
cout << " ====== MEDICARE HOSPITAL LOGIN =======";

cout<<"\n"<<endl;
cout<<"\n"<<endl;
cout<<"\n"<<endl;
cout<<" *** ****** ******* ************* **** *** "<<endl;
cout<<" *** ******** ********* ************* ***** *** "<<endl;
cout<<" *** ** ** *** *** *** ** *** "<<endl;
cout<<" *** ** ** *** ******** *** *** ** *** "<<endl;
cout<<" *** ** ** *** ******** *** *** ** *** "<<endl;
cout<<" *** ** ** *** *** *** *** *** ** *** "<<endl;
cout<<" *** ** ** *** *** *** *** ** *** "<<endl;
cout<<" ********** ******** *********** ************* *** ***** "<<endl;
cout<<" ********** ****** ********* ************* *** **** "<<endl;
cout<<"\n"<<endl;
cout<<"\n"<<endl;
cout<<"\n"<<endl;
cout<<"\n"<<endl;
cout<<"\n"<<endl;
system("color 75");
cout<< " 1 Admin login 2 Customer login "<<endl;
cout<< "\n"<<endl;
cout<<"Select 1, 2" <<endl;
cout<<"Enter option " <<endl;
cin>>opt;
cout<<"\n"<<endl;

switch (opt)
{
case 1:
{

while (counter<=2)
{
cout<< "Enter Username "<<endl;
cin>> Username;
cout<< "Enter Password "<<endl;
cin>> Password;

if((Username=="admin")&&(Password=="123"))
{
system("cls");
cout<< "Welcome to Admin Account! "<<endl;
break;
cout<<"\n"<<endl;
}
else
{

cout<< "Invalid user, Check your login details " <<endl;
}
counter++;
}
if(counter<=2)
{
cout<< "Welcome to admin Account! "<<endl;
}
else
{
cout<< "Unauthorized User contact help desk " <<endl;
}
}
case 2:

{
cout<< "Enter Username "<<endl;
cin>> Username;

cout<< "Enter Password "<<endl;
cin>> Password;

if((Username=="afra")&&(Password=="123"))

{
system("cls");
cout<< "Welcome to customer Account! "<<endl;
cout<<"\n"<<endl;
break;

}
else
{
cout<< "Invalid user, Check your login details " <<endl;
}
}
}
void main()
{
system("pause");
}
1
2
3
4
using namespace std;

{ //<Why is this brace here?
int counter=0;
Topic archived. No new replies allowed.