This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

what is wrong here

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?

Parents
  • You didn't specify how the actual behavior of the code differs from your expectation, so the diagnosis of the problem is a bit difficult.

    what is wrong?

    Unless the two pointers point to a volatile data type, the compiler can optimize out all but the first access to the variables.

    Some other, minor issues are:

    1. The possibility of an endless loop. If the condition is never met, is it okay if the program just sits there for all eternity, waiting?

    2. Unnecessary use of a goto - a while()-loop could do the same job here.

Reply
  • You didn't specify how the actual behavior of the code differs from your expectation, so the diagnosis of the problem is a bit difficult.

    what is wrong?

    Unless the two pointers point to a volatile data type, the compiler can optimize out all but the first access to the variables.

    Some other, minor issues are:

    1. The possibility of an endless loop. If the condition is never met, is it okay if the program just sits there for all eternity, waiting?

    2. Unnecessary use of a goto - a while()-loop could do the same job here.

Children
No data