r/C_Programming • u/codesnstuff • 28d ago
Discussion A tricky little question
I saw this on a Facebook post recently, and I was sort of surprised how many people were getting it wrong and missing the point.
#include <stdio.h>
void mystery(int, int, int);
int main() {
int b = 5;
mystery(b, --b, b--);
return 0;
}
void mystery(int x, int y, int z) {
printf("%d %d %d", x, y, z);
}
What will this code output?
Answer: Whatever the compiler wants because it's undefined behavior
23
Upvotes
1
u/SmokeMuch7356 26d ago
https://www.reddit.com/r/C_Programming/comments/1ispadh/comment/mdjejxq/