How much space is allocated for the following code?

advertisements

How much space is allocated by the expression

int *a[10];

If size of int is 4 and size of int pointer is 2.

options are 2, 4, 20, 40

I am poor at pointers please help me.


In declaration int *a[10], a is array of pointer to int of 10 size, so size = sizeof (int*) * 10.

You can apply sizeof operator to print its size:

printf("sizeof = %zu", sizeof(a));

If suppose in some system sizeof pointer to int is 2 (as you says in question) then size will be 20 bytes.