Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Extra Pointer Shenanigans

1. Determine the output of this code.


int ***p;
int **q;
int *r;
int s[] = {1,3,3,7};;
p = &q;
q = &r;
r = s;
printf("%d\n", *(&(*(**p + 3)) - 2));

2. Determine the output of this code.


int arr[2][2][5] =
{
{
{1,3,5,7,9},
{0,2,4,6,8}
},
{
{13,14,15,16,17},
{28,27,26,25,24}
},
};
printf("%d\n", *(((*arr + 1)[1] + 2) + 1));

3. Determine the output of this code.


char *str[] = {"C programming", "is", "super", "fun!" };
printf("%s\n", &(*(*(str + 2) + 2)));

4. What (if anything) is wrong with the following code:


char *str[][2] = {{That,Boy}, {Aint, Right}};
for(int i=0; i < 2; i++)
for(int j=0; j < 2; j++)
printf(%s , j[i[str]]);

You might also like