C++ (or mine) stupidity

1
2
3
short main[] = {

};

Yes, it compiles (and crashes)! BUT WHY?
You can't return a pointer to the shell?
Never mind...
How the hell does this even compile? what sense does it make?
The function is supposed to return a short, but you never write a return sentence, and also, the function name is main[] , which might make the syntax check go nuts . And there's an equal symbol!

WTF?
Last edited on
PROTIP: It's an array.
Oh yeah; we're all thinking it's the function, main(); but of course, it's an array called main.
This is weird...
http://www.ioccc.org/1984/mullender.hint
I found this 10 seconds after I posted the question (stupid me). I thought I'll delete the question but chrisname replied too fast...

Btw, I started learning asm few days ago (because I don't need to go to school this week, thanks to epidemic flu :-)
At first it was easy. But today i tried to figure out why my number-to-string function doesn't work when I mov ax,cx (it worked when I moved bx to ax) And OH SH*T, IT CONVERTS AL TO STRING, NOT WHOLE AX! I got a head ache...
ASM is irksome... I assume you're learning Intel syntax? You should learn AT&T syntax too; despite which you use, both will be seen on the internet.

In some ways asm is extremely fun. You get the feeling of actually programming the computer, not just the compiler; mostly due to manipulating the CPU's registers.
Topic archived. No new replies allowed.