vcdk
Joined 5 months ago
Karma
-1
Submissions
5
Member since
May 13
Joined 5 months ago
$ /bin/cat x.c; gcc -w -o x x.c; ./x
#include <stdio.h>
int main()
{
int a = 5;
a += a++ + a++;
printf("a = %d\n", a);
}
a = 18
Not what I expected.
This must be how it works:- The first a++ expression results in 5, after a = 6 - The second a++ expression results in 6, after a = 7 - Only then the LHS a is evaluated for the addition-assignment, so we get: a = 7 + 5 + 6 = 18
The Vibe-Coding Detox Klinic is a specialist consultancy for organisations whose PHP applications have developed an unfortunate dependency on autocomplete.
Founded by a senior engineer with 30 years of clean diagnoses, we offer rehabilitation, re-architecture, and when prognosis is severe, a dignified rewrite.
https://vibecodingdetox.eu/