I can't understand what the following code is doing on s:
s
if(!s--)
s is an int
int
! is called negation operator. It is a logical operator.
!
negation
See the wikipedia entry here.
The order in which it executes
0
if
Actually, it's misleading.
You are testing is s is different from 0 (with if (!s)). And then, afterward, whatever the result is, you're decreasing it.
if (!s)
So, it's two different operations. It could be written this way :
if (!s) { s--; //... } else { s--; }
!is callednegationoperator. It is a logical operator.See the wikipedia entry here.
The order in which it executes
sis0or not , ifsis0,ifcondition is success [thanks to the!operator], otherwise, failure.sby one unit.ifcondition, continue the execution [code underifcondition, or next block of code].