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

Howdy, Stranger!

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

Categories

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.