I accidentally typed while(x,0) instead of while(x<0). The code of course didn't work as planned nor got compiler errors so i took a damn hour to find the mistake.
Why it didn't get a compiler error? And what does the , do in the while loop?
I accidentally typed while(x,0) instead of while(x<0). The code of course didn't work as planned nor got compiler errors so i took a damn hour to find the mistake.
Why it didn't get a compiler error? And what does the , do in the while loop?
 
    
    while(x,0)
comma is treated as binary operator and it will return 0, so your loop condition will go false.
 
    
    In C, a comma is "a binary operator that evaluates its first operand and discards the result, and then evaluates the second operand and returns this value (and type)."
Since 0 is false then your code was exiting the loop.
