case bypasses intialisation of local variable

June 14, 2011 at 12:08:16
Specs: Windows XP
please help me out....

case 2:
clrscr();
gotoxy(20,10);
cout<<"ENTER THE PASSWORD " ;
cin>>j;
gotoxy(20,30);
cout<<"CHECKING PLEASE WAIT.....................";
sleep(2000);
if(j==r)
{
Y:
ofstream fout("Train1.dat",ios::app);
tr.input();
fout.write((char*)&tr,sizeof(tr));
fout.close();
gotoxy(10,30);
cout<<"DO YOU WISH TO CONTINUE UPDATING ?(Y/N)";
cin>>n;
textcolor(WHITE);
if(n=='y'||n=='Y')
goto Y;
goto Z;
}
else
goto Z;
case 3:tick.reservation();
goto Z;
case 4:tick.cancellation();
goto Z;
case 5:tick.display();
goto Z;
case 6:exit(0);
}
getch();
}


this is a part of a switch case.... this part gives an error- case bypasses intialisation of local variable. what is this , give me a solution..


See More: case bypasses intialisation of local variable

Report •


#1
June 14, 2011 at 13:47:36
There's not enough code there to see what the problem is. I can only guess that "r" may be the variable that you are not initializing.

But I can say that this is some of the most horribly inelegant C++ code that I have ever seen. For starters, you don't not need to use "goto" statements; they do nothing but make the code practically unreadable.


Report •

#2
June 15, 2011 at 00:43:17
what is case bypasses intialisation of local variable?...

Report •

Related Solutions


Ask Question