the address of the array is contained in the array name that is a pointer to the array it means when we are declaring an integer array a[5] we are getting 10 bytes for the array elements and two bytes for the pointer a?
means 12 bytes are occupied in fact
is it so and i just want to confirm to store a address(pointer variable) how many bytes we require is it 2 bytes?

> means 12 bytes are occupied in fact
Nope, guess again.
Arrays are not pointers.

if you have a[10]

a refers to the address of the first element of the array
so you will have 10 * sizeof(int) bytes occupied by the array.

to be clear:
a = &a[0]
(a+1) = &a[1]

and
*a = a[0]
*(a+1) = a[1]
and so on..

There can be array of ponters.Since a pointer variable always contain an address,an array
of pointers would be nothing but a collection of addresses.The addresses present in the array of pointers can be addresses of isolated variables or addresses of array elements
or any other address.All rules that apply to an ordinary array of pointers as well.I think a program would clarify the concept.

main()
{
int *arr[4];    /*array of integer pointers*/
int i=31,j=5,k=19,l=71,m;


arr[0]=&i;
arr[1]=&j;
arr[2]=&k;
arr[3]=&l;


for(m=0;m<=3;m++)
printf("%d",*(arr[m]));
}

boyz is banned. I thought this thread would be closed.

boyz is banned. I thought this thread would be closed.

We don't close threads just because the thread starter gets banned.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.