I tried compiling the following code in Linux and VS 2008:
#include <iostream> // this line has a ".h" string attached to the iostream string in the linux version of the code
using namespace std; // this line is commented in the linux version of the code
void main()
{
int a=100;
char arr[a];
arr[0]='a';
cout<<"array is:"<<arr[0];
}
This line works in the g++ version but does not work in the Visual Studio. It throws the following error:
1>c:\users\bibin\documents\visual studio 2008\projects\add\add\hello.cpp(7) : error C2057: expected constant expression
1>c:\users\bibin\documents\visual studio 2008\projects\add\add\hello.cpp(7) : error C2466: cannot allocate an array of constant size 0
1>c:\users\bibin\documents\visual studio 2008\projects\add\add\hello.cpp(7) : error C2133: 'arr' : unknown size
Is this a valid statement ?? How can two compilers have different interpretation of the same langauge