Strange thing with static Array!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello dear GCC staff

I have strange thing with my C++ code.

as I knew and learned that we can't compile a dynamic size with a
static array at compile time

but my code below can be compiled and I can change the size every time
I run the code

also it is working at run time!!

thank you very much




################# Code #################

#include <iostream>
using namespace std;

int main()
{

        int array_size;

        cout << "Enter the array size: ";
        cin >> array_size;

        int ali[array_size];

        for(int i = 0; i < array_size; i++)
                ali[i] = 0;

        for(int i = 0; i < array_size; i++)
                cout << ali[i] << "   ";
        cout << endl;

        return 0;
}

################# End of The Code #################

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux