I am writing a program in which i am using a if statement to check if some condition is true, if that condition indeed is true I increment a variable by 1 which essentially works as a counter. The problem is that as soon as the statement is true the variable either gets incremented endlessly or by random number.
I have been trying to use some clause to break out of this statement if condition meet but with no luck
don't use a goto like bourgound said. but yeah use a return or break depending on the situation. and im a little confused on your if statement..you increment it by 1 and then you put an ifstatement saying if it is true it gets incremented then to break some loop? maybe just put another statement in line 1 like if(res_vect_angle >=60 && res_vect_angle <=100 && left_mag_b >100 && left_hook_count != 1) //or what ever value it is when it is incremented
thanks for you suggestions guys, Maybe my question is misunderstood but the problem i had before i added the break; statment was that whenever the if statement if(res_vect_angle >=60 && res_vect_angle <=100 && left_mag_b >100) was true the left_hook_count++; variable was endlessly incremented.
Now i tryied to fix this by adding a break, how i want this break to work is, whenever the statement is true add 1 to the left_hook_count++; variable and then break.
Regards and really sorry if my question was unclear