Why does the code below work without any crash @ runtime ?
And also the size is completely dependent on machine/platform/compiler!!. I can even give upto 200 in a 64
Your code has Undefined Behavior. That means it can do anything or nothing. Depending on your compiler and OS etc., it could crash.
That said, with many if not most compilers your code will not even compile.
That's because you have void main
, while both the C standard and the C++ standard requires int main
.
About the only compiler that's happy with void main
is Microsoft’s, Visual C++.
That's a compiler defect, but since Microsoft has lots of example documentation and even code generation tools that generate void main
, they will likely never fix it. However, consider that writing Microsoft-specific void main
is one character more to type than standard int main
. So why not go with the standards?
Cheers & hth.,