Possible Duplicate:
Why doesn’t a+++++b work in C?
I got this from page 113 on the "An Embedded Software Primer" by David Simon.
I saw this statement below:
iHoursTemp = iHoursTemp + iZoneNew ---iZoneOld;
Can you really have three minus signs in this line? What does a triple minus sign mean?
I believe it is a C programming statement.
*&n is equivalent to n . Thus the value of n is printed out. The value of n is the address of the variable p that is a pointer to int .
In programming, a double ampersand is used to represent the Boolean AND operator such as in the C statement, if (x >= 100 && x >= 199).
It is equivalent to:
iHoursTemp = iHoursTemp + (iZoneNew--) - iZoneOld;
This is in accordance with the maximal-munch principle
The correct answer is (as Rob said) the following:
iHoursTemp = iHoursTemp + (iZoneNew--) - iZoneOld;
The reason it is that way and not
iHoursTemp = iHoursTemp + iZoneNew - (--iZoneOld);
is a convention known as maximum munch strategy, which says that if there is more than one possibility for the next token, use (bite) the one that has the most characters. The possibilities in this case are -
and --
, --
is obviously longer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With