This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Strange thing with static Array!
- From: gfx art <xgrafix at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 28 Feb 2009 12:47:47 +0300
- Subject: Strange thing with static Array!
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 #################