There's a line in a program in C Primer Plus that is:
One set of parenthesis works, but is there a reason he put in two or is it just a typo?Code:cans += ((sq_feet % COVERAGE == 0)) ? 0 : 1 ;
Thanks
There's a line in a program in C Primer Plus that is:
One set of parenthesis works, but is there a reason he put in two or is it just a typo?Code:cans += ((sq_feet % COVERAGE == 0)) ? 0 : 1 ;
Thanks
There is an off-chance that they meant to type this, to just emphasis the precedence.
But the precedence of ?: is so low that you don't need any of themCode:cans += ((sq_feet % COVERAGE) == 0) ? 0 : 1 ;
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
That crossed my mind too.
Okay, thanks.