Hi all,
I am a newbie in C, and a bit curious with this "goto" statement.
For instance, I create a simple code below
#include <stdio.h>
int main ()
{
int a;
a = 1+1;
if (a!=2)
{
goto error;
}
error:
printf("error is here\n");
return 0;
}
it still prints me the printf function, although the condition is not satisfied.
I can avoid this by creating an else goto noterror. But what if I need a lot of goto, does it mean I need to also create a gotonoterror (under else) for each part?
why does it keeps going to goto, although the condition is not satisfied for the above code? any other way to avoid this?
Thank you