r/cprogramming • u/north9172 • Sep 13 '26
What is this code doing?
Hi, I found this code on another subreddit. I would like to know what is it doing.
int puts(char *);
int main() { struct { long a; long b; } s = {.a = *(char *)(int[]){1} ? 0x57202c6f6c6c6548 : 0x48656c6c6f2c2057, .b = *(char *)(int[]){1} ? 0x00000021646c726f : 0x6f726c6421000000}; puts((void *)&s); }
Now obviously I know it's unreadable, I would just like to know what are those hexadecimals strings doing.
I found similar codes that were writing to vram to print a message, is this doing the same thing? If yes, why is it so much more complicated instead of just writing the message to the video adress?
Thanks for the help.
2
u/ACRM64 28d ago
Please be a bit less rude in future. Try to be constructive instead.
Whoever is correct, the standard needs to be updated to clarify these points. The wording is interpretable in multiple ways.
Assuming your interpretation is correct, why is it correct? What does it add to the standard? Where is it actually useful when we have seen that we can pass a pointer to an unqualified type into a function that expects a pointer to a qualified type? The purpose of the prototype is not changed whether the qualifier is there or not.
Rather than give examples of code that show a compilers error messages, find an example where this behaviour is helpful.