Error Output when a Character is entered

Hey guys, can you please help me find the error in my program..Everytime I enter a letter/character...The program just stops...Is there something wrong with my code....?
heres my code...

"Don't mind the cases"



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
void main()
{
int rl;
/////////////////////////////////
do
{
try
{
cout<<"\n\n\n\t<<<<<<<PCC Class Election>>>>>>>";
cout<<"\n\n\n\n\t[1] Registration\n\n";
cout<<"\t[2] Login as Voter\n\n";
cout<<"\t[3] Login as Admin\n\n";
cout<<"\t[4] Exit\n\n\n";
cout<<"\tselect your option: ";
cin>>rl;
/////////////////////////////////////
if(rl<1||rl>4)
throw rglg();

////////////////////////////////////
system("cls");
////////////////////////
switch(rl){
case 1:
{
voter[i]=reg();
i++;
maxvoter++;
break;
}
case 2:
prelog(voter, maxvoter);
break;
case 3:
adminlogin(voter,maxvoter);
break;
case 4:
exit(0);
}//end of try
}//end of switch
////////////////////////////////
catch(rglg)
{
cout<<"\n\n\tError...Try again...";
getch();
system("cls");
}//end of catch
/////////////
}while(rl!=4);
}
Last edited on
That's what cin does. You ask it for an int, so a string causes a bit of a crash.
To prevent it, see http://www.cplusplus.com/forum/beginner/28223/#msg151683
Topic archived. No new replies allowed.