S
sinbad
hi, check out the following program ...
a.c
-----
extern void fun();
int a[10];
int main ()
{
fun ();
}
b.c
-----
extern int *a;
void fun()
{
a++;
printf ("%d",a);
}
If i compile the above two files together ...
what should be the behavior of variable a in fun() , it should be
pointing to the array right ? More specifically this should give a
compile error , as i expected because in file a.c , a is an array that
means the memory location pointed to by 'a' is a constant ( a is a
constant pointer , although not completely correct , we can think like
that) and in file b.c , we are declaring 'a' as a non const pointer to
integer ... There is a type mismatch here ... Can somone explain
this ...
thanks
sinbad
a.c
-----
extern void fun();
int a[10];
int main ()
{
fun ();
}
b.c
-----
extern int *a;
void fun()
{
a++;
printf ("%d",a);
}
If i compile the above two files together ...
what should be the behavior of variable a in fun() , it should be
pointing to the array right ? More specifically this should give a
compile error , as i expected because in file a.c , a is an array that
means the memory location pointed to by 'a' is a constant ( a is a
constant pointer , although not completely correct , we can think like
that) and in file b.c , we are declaring 'a' as a non const pointer to
integer ... There is a type mismatch here ... Can somone explain
this ...
thanks
sinbad