Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

C/C++ Best Practice: is goto an usable keyword?

ArturInboxArturInbox Posts: 2Member
Greetings!

Well, everybody says goto is not a usable keyword. That seems to be everyone's opinion. Yet, it is defined as standard in most languages: including C and C++ code. What's the real story? Is goto REALLY not usable?

Before you start calling me a dinosaur, take a look at these lines:
[code]
int main()
{
while(1)
{
CheckTemperature();
CheckControls();
SoundAlarm();
}
}
[/code]

Embedded systems use these much: a never-ending tasklist. Another option is the for loop, but not all compilers accept:
[code]
int main()
{
for(;;)
{
CheckTemperature();
CheckControls();
SoundAlarm();
}
}
[/code]

A goto suggestion:
[code]
int main()
{
tasklist:
CheckTemperature();
CheckControls();
SoundAlarm();
goto tasklist;
}
[/code][b][/b][b][/b]
Sign In or Register to comment.