"gullu" <at********@gmail.comwrote in message
news:11*********************@y5g2000hsa.googlegrou ps.com...
Hi,
I know that it is a very wierd question but anyways, I will ask it and
will really appreciate of someone could help me out.
Is there any way to use global labels in C/C++.
I want to implement a piece of code that has a functionality similar
to the code shown below.
int main()
{
LabelTest();
printf("This MUST NOT be printed.\n");
label1:
print("This MUST be printed.\n");
return 0;
}
void LabelTest()
{
goto label1;
}
Is there anyway to achieve some functionality like this.
Yes, by redesigning the program. A program that needs a goto is usually
poorly designed. For instance...
int main()
{
if ( PrintLabel() )
printf("This MUST NOT be printed \n");
printf("This MUST be printed \n");
return 0;
}
bool PrintLabel()
{
return false;
}
If you are trying to find ways to use GOTOs better in a C++ program, then
what you probably actually need to do is learn OOPs programming. What is it
you hope to achieve by using a goto anyway?
Regards,
Jim Langston