CKTIS / C
Increment operator ++
Prefix `++` yields the operand’s updated value; postfix `++` yields its previous value. These values can be equal: in C23, if a `bool` operand is already `true`, both forms yield `true` and leave the operand unchanged.
Version: C23; repository compiler flag, production runtime not attested
Syntax
++operand
operand++++n yields the incremented value; n++ yields the previous value but also updates n. The operand must be a modifiable lvalue of real or pointer type; constants and const objects are excluded.
For pointers, the increment means one element, not one byte; the result must remain within the same array or one past it.
n++ + n has undefined behavior: the read and modification are unsequenced. Use separate statements. Overflow of an ordinary signed integer type is also undefined.
Examples
#include <stdio.h>
int main(void)
{
int n = 5;
int before = n++;
int after = ++n;
printf("%d %d %d\n", before, after, n);
return 0;
}
Result
5 7 7
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.