How to answer this interview test about constant pointers?

Viewed 9377

I had an interview in which they had asked me this question

#include<stdio.h>
int main ()
{
int* const p=NULL;
int const *q=NULL;
p++;
q++;
printf("%d\n",p);
printf("%d\n",q);
}

How will above program behave

a) p will increment 4 bytes;
and q will also increment 4 bytes;

b) p will be zero
q will point to memory 4 bytes ahead;

c) error will come in above program

I am not able to understand what is the difference between the statements

int* const p=NULL;
int const *q=NULL;
5 Answers
Related