Hello friends,
i have some doubt and hope i will get an satisfactory answer from here.
1) Can memory addresses be negative........i have initialized an array and check the address of element and found it negative...so i want to know can it be negative and if yes then how addresses are assigned to variables.
2)is negative subscript of array allowed in C? if yes then what is the meaning of it?
i found on net that array[-1] will give the last element of array, and also i found that array[-1] equal to *(array-1), then how these two can be same?
One more thing friends....just take a look this code:
#include<stdio.h>
int main()
{
int i,array[10];
array[0]=0;
array[1]=1;
array[2]=2;
array[3]=3;
array[4]=4;
array[5]=5;
array[6]=6;
for(i=-6;i<10;i++)
printf("%d \t%d\n ",array+i,array[i]);
printf("\n");
return 0;
}
And the Out put on my machine is....
-1078159552 0
-1078159548 -1078159552
-1078159544 -1078159552
-1078159540 0
-1078159536 0
-1078159532 0
-1078159528 0
-1078159524 1
-1078159520 2
-1078159516 3
-1078159512 4
-1078159508 5
-1078159504 6
-1078159500 134518452
-1078159496 -1078159464
-1078159492 134513849
Question is how array[-1],array[-2 ] element are zero......is there ny reason???
help plz