Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

I'm learning c++

Name: Anonymous 2010-09-14 8:24

And my compiler is letting me do something weird.


If I do this:

int x; //matrix-size

cin >> x;

int array[x];

I can compile. I don't even get a warning. (I'm using the Codelite IDE for Linux, compiler is g++)

Does this work in c++ or is my compiler just fucking with me?

Name: Anonymous 2010-09-15 5:39

>>14
Yes it's valid C. It's not valid C for creating a dynamic array. That's the important difference. The value of x has to be known at compile time, or the compiler will (a) give an error if it's a decent compiler or (b) compile with a random value for x (Typically whatever value is in that RAM block at that very moment, which can lead to hilarious results)

I'm afraid g++ is giving me the (b) option and I'm not happy with it, which is why I made the thread.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List