Hello, was hoping someone could comment on the use of && in C.
I'm writing a program that is parsing a file with two pointers, stopping when the "contents" at those pointers become certain values, incrementing the pointers in a while loop otherwise.
My code doesn't seem to work as expected, the problem seems to be that I don't understand the && operator, although I thought I did for the longest time getting results as I expected, although that was using GCC on Linux system.
I am now trying lcc on windows.
I've written some simple code that replicates my problem in understanding:
So when I run the code above I would expect the while loop to run infinitly ( not that I want it too) because a== 5 and b==6 never happens at the same time. However, when I run the program it exits the loop when a == 5, as evidenced(tested) with my printf. So it seems to me that when a == 5 the && is acting like an OR operator " || "; that it will leave the loop if only one of the conditions are met.
a = 2;
b = 3;
while( (a != 5) && (b != 6) )
a = a+1;
b = b+2;
printf("a is %d and b is %d\n", a,b);