In my UG days, I spent a lot of time with the C programming language. Had forgotten most of it.
But now (Feb 2023) I'm a TA for a lab course using C. Noting down stuff that I came across again..
#include<stdio.h>
int main() {
int a=3, b;
= sizeof(a=10);
b ("a=%d, b=%d\n", a, b);
printf// a=3, b=4
// Value of b is compiler dependent though.
return 0;
}
(Thanks to Kevin for telling me this.)
Multiple sequence points => undefined behaviour.
#include<stdio.h>
int main() {
int a=3;
("%d\n", a++ + ++a);
printf// 8
// Needn't be so though. It's undefined behaviour.
return 0;
}
Evaluation could be one of the following:
((a++) + ++a))
(a++ + (++a))
(Thanks to Kevin for reminding me about this.)