Array of pointers to integers.i.e.Array of integer pointers.Since,Integer pointer store address of one integer.Therefore,Array of pointers to integers will store addresses many integers.
#include<stdio.h>
int main()
{
int a[]={10,20,30};/*array of integers*/
int* arr[]={a,a+1,a+2};/*array of integer pointers so contains addresses*/
printf("\nAddresses of integers:\n");
printf("address of a=%u\n",a);/*no & needed as name of the array gives base address.*/
printf("address of a+1=%u\n",(a+1));
printf("address of a+2=%u\n",a+2);
printf("\nAddrs of integers are stored in arr so each arr[i] is an address:\n");
printf("arr[0]=%u\n",arr[0]);
printf("arr[1]=%u\n",arr[1]);
printf("arr[2]=%u\n",arr[2]);
printf("\nsince arr[i] are address so *arr[i] gives values stored at address stored in them\n");
printf("\narr[0]=%u\n",*arr[0]);
printf("arr[1]=%u\n",*arr[1]);
printf("arr[2]=%u\n",*arr[2]);
return 0;
}
/*
Addresses of integers:
address of a=3216726456
address of a+1=3216726460
address of a+2=3216726464
Addrs of integers are stored in arr so each arr[i] is an address:
arr[0]=3216726456
arr[1]=3216726460
arr[2]=3216726464
since arr[i] are address so *arr[i] gives values stored at address stored in them
arr[0]=10
arr[1]=20
arr[2]=30
*/
#include<stdio.h>
int main()
{
int a[]={10,20,30};/*array of integers*/
int* arr[]={a,a+1,a+2};/*array of integer pointers so contains addresses*/
printf("\nAddresses of integers:\n");
printf("address of a=%u\n",a);/*no & needed as name of the array gives base address.*/
printf("address of a+1=%u\n",(a+1));
printf("address of a+2=%u\n",a+2);
printf("\nAddrs of integers are stored in arr so each arr[i] is an address:\n");
printf("arr[0]=%u\n",arr[0]);
printf("arr[1]=%u\n",arr[1]);
printf("arr[2]=%u\n",arr[2]);
printf("\nsince arr[i] are address so *arr[i] gives values stored at address stored in them\n");
printf("\narr[0]=%u\n",*arr[0]);
printf("arr[1]=%u\n",*arr[1]);
printf("arr[2]=%u\n",*arr[2]);
return 0;
}
/*
Addresses of integers:
address of a=3216726456
address of a+1=3216726460
address of a+2=3216726464
Addrs of integers are stored in arr so each arr[i] is an address:
arr[0]=3216726456
arr[1]=3216726460
arr[2]=3216726464
since arr[i] are address so *arr[i] gives values stored at address stored in them
arr[0]=10
arr[1]=20
arr[2]=30
*/
No comments:
Post a Comment