F
Frederick Gotham
If you wish to override the natural operator precedence and associativity
in C, you can use parentheses:
5 * (4 - (2 + 7))
However, I was surprised to discover (by testing) yesterday that some
operators are unaffected by parentheses. I expected the following program
to print:
Func2() called, returns 0.
Func1() called, returns 0.
However, with my own compiler, it prints:
Func1() called, returns 0.
The parentheses used in "main" have no effect on the && operator.
#include <stdio.h>
int Func1(void)
{
puts("Func1 called, returns 0.");
return 0;
}
int Func2(void)
{
puts("Func2 called, returns 0.");
return 0;
}
int Func3(void)
{
puts("Func3 called, returns 0.");
return 0;
}
int main(void)
{
Func1() && ( Func2() && Func3() );
}
Any thoughts on this?
in C, you can use parentheses:
5 * (4 - (2 + 7))
However, I was surprised to discover (by testing) yesterday that some
operators are unaffected by parentheses. I expected the following program
to print:
Func2() called, returns 0.
Func1() called, returns 0.
However, with my own compiler, it prints:
Func1() called, returns 0.
The parentheses used in "main" have no effect on the && operator.
#include <stdio.h>
int Func1(void)
{
puts("Func1 called, returns 0.");
return 0;
}
int Func2(void)
{
puts("Func2 called, returns 0.");
return 0;
}
int Func3(void)
{
puts("Func3 called, returns 0.");
return 0;
}
int main(void)
{
Func1() && ( Func2() && Func3() );
}
Any thoughts on this?