Location: If I had a webcam u could have seen me, before your eyes.
Posts: 459
Re: array initialization
Because after declaration the name(i.e x ) of the array points to the 1st element of the array..Hence when u write x={1,2,3} after declaration..The compiler tries 2 give the 1st element i.e. X[0] those vals. Which is not possible...Hence....
__________________
Searching for dell studio 15 ??
dell studio 15 review @ my blog
vandit007.blogspot.com
And remember the stylus that comes along with the touchscreens isnt meant for cleaning your ears !!
let us undertand some basic things about array.
the given array is a[n].
so when we write a[n], we are telling the machine that it is an array with n elements.
the "n" is just an number,integer.
and the variable "a" is actually a pointer to the base address of the array, that is a[0].
so int x[3];
x={1,2,3} is wrong, as it means we are trying to give some value to the variable x, though this is not a correct way either.
so the only way to add values to array while initialisation is
x[]={ ....}
or x[3]={..}
It will result into a Syntax error simple. If you were the developer than you should have added this feature in it. Any Programming language has a specific Syntax which we should follow. And this if not followed will result into a Syntax error.