K
karthikbalaguru
Hi,
For the below code, though i get warning in gcc, it works fine.
But, in VC++ compiler, it is showing compile-time error .
int main(void)
{
int a[2][2]={
1,2,
3,4,
};
int *aptr;
aptr=a;
printf("output is %d",*(aptr+1));
return 0;
}
I get the below error in VC++ environment :-
error C2440: '=' : cannot convert from 'int [2][2]' to 'int *'
But, in gcc i get the correct output along with
the below warning :-
warning: assignment from incompatible pointer type
In gcc, i get the correct output as below -
output is 2
Why does the assignment in the above code fail in
VC++ but works fine in the gcc ?
Which is the correct behaviour ?
The above code raises many other queries in my mind -
I wonder if gcc is meeting the C standard or VC++ ?
Any ideas ?
Thx in advans,
Karthik Balaguru
For the below code, though i get warning in gcc, it works fine.
But, in VC++ compiler, it is showing compile-time error .
int main(void)
{
int a[2][2]={
1,2,
3,4,
};
int *aptr;
aptr=a;
printf("output is %d",*(aptr+1));
return 0;
}
I get the below error in VC++ environment :-
error C2440: '=' : cannot convert from 'int [2][2]' to 'int *'
But, in gcc i get the correct output along with
the below warning :-
warning: assignment from incompatible pointer type
In gcc, i get the correct output as below -
output is 2
Why does the assignment in the above code fail in
VC++ but works fine in the gcc ?
Which is the correct behaviour ?
The above code raises many other queries in my mind -
I wonder if gcc is meeting the C standard or VC++ ?
Any ideas ?
Thx in advans,
Karthik Balaguru