D
dam_fool_2003
Hai,
For a notes in web is saw the following lines:
Accessing an item at an arbitrary position:
If the items in the
sequence are numbered 0, 1, ... and we know the address in
memory of the first item, then the address of the ith
item is
(address of first item) + i * (size of an item)
So I tried the following to see the address of the first item (ie 2):
int main(void)
{
unsigned int y[5]={2,3,6,7,4},j;
printf("Adder =%p and the value =%d\n",&y[0] + 1 * sizeof (int),y[0]+1
* sizeof(int));
for(j=0;j<5;j++)
printf("%p %d\n",&y[j],y[j]);
return 0;
}
OUTPUT:
Adder =8fb28 and the value =6
8fb18 2
8fb1c 3
8fb20 6
8fb24 7
8fb28 4
In the above I was excepting
"Adder = 8fb18 and the value = 2"
But it gave me a different answer. Why?
For a notes in web is saw the following lines:
Accessing an item at an arbitrary position:
If the items in the
sequence are numbered 0, 1, ... and we know the address in
memory of the first item, then the address of the ith
item is
(address of first item) + i * (size of an item)
So I tried the following to see the address of the first item (ie 2):
int main(void)
{
unsigned int y[5]={2,3,6,7,4},j;
printf("Adder =%p and the value =%d\n",&y[0] + 1 * sizeof (int),y[0]+1
* sizeof(int));
for(j=0;j<5;j++)
printf("%p %d\n",&y[j],y[j]);
return 0;
}
OUTPUT:
Adder =8fb28 and the value =6
8fb18 2
8fb1c 3
8fb20 6
8fb24 7
8fb28 4
In the above I was excepting
"Adder = 8fb18 and the value = 2"
But it gave me a different answer. Why?