int main()
{
for (int z = 0; z != 100; z++)
{
for (int y = 0; y != 100; y++)
for (int x = 0; x != 100; x++)
if (y == 50) goto multibreak;
multibreak:
}
return 0;
}
Why this compiler output?
1.cpp: In function 'int main()':
1.cpp:9:2: error: expected primary-expression before '}' token
1.cpp:9:2: error: expected ';' before '}' token
I rarely use gotos, as they're evil, but I believe they must be associated with a statement. The compiler is complaining that there is no statement between your label and the closing brace. You can just follow its advice and supply a ;, which is a null statement.
1 2 3 4 5 6 7 8 9 10 11 12
int main()
{
for (int z = 0; z != 100; z++)
{
for (int y = 0; y != 100; y++)
for (int x = 0; x != 100; x++)
if (y == 50) goto multibreak;
multibreak:
; // null statement
}
return 0;
}
Andy
P.S. I don't get why you're testing y after you enter the x loop?