We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
ive got this code and some works but this is the problem
tryagin: if ( *var1 == 22 && *var2 == 75 ) goto end;
goto tryagin;
what is wrong?
In addition to everything Chistoph said, there is no end label to goto.
Whenever you get an urge to use goto - purge it. Think about how you can rewrite the code. A good teacher will reject code containing goto. Especially since you can _often_ rewrite the code in a very elegant way.
And also try a bit of logic rewrites:
repeat: if ( *var1 == 22 && *var2 == 75 ) goto end; goto repeat; end:
Without goto:
while (!(*var1 == 22 && *var2 == 75)) ;
Rewritten logic that is easier to read:
while (*var1 != 22 || *var2 != 75) ;
Note that a list of && operations can be converted to a list of || operations whith each term and the end result inverted.
And a list of || operations can be converted to a list of && operations with each term and the end result inverted.
As you can see, the goto normally doesn't help to produce shorter or more elegant code. It produces hard-to-read code, and can destroy some of the optimizations in the compiler because the goto is harder to analyse.