I have the following code:
... int n; cin >> n; int numbers[n]; ...
It compiled with netbeans on mac using g++ (I think) and it didn't compile using vs2008 on windoze. Why is it so hard to make it work with every compiler? The size of the array is known before allocating it.
EDIT: I know abot std::vector. Actually this was part of a homework and i started it at work on a mac, then got home and was surprised that it didn't work on vs2008. Thanks for all the answers. But I still find it logical that if the compiler can generate some code like alloc(123) where the value 123 is hardcoded, why can't it generate something like alloc(n) where you get n from a memory address that holds an int n or something. It just seems more logical to allow something like this by default.