Whats the problem with int *p=23;

Posted by piemesons on Stack Overflow See other posts from Stack Overflow or by piemesons
Published on 2010-03-29T13:22:41Z Indexed on 2010/03/29 13:33 UTC
Read the original article Hit count: 271

Filed under:
|

Yesterday in my interview I was asked this question. (At that time I was highly pressurized by so many abrupt questions).

int *p;
*p=23;
printf('%d',*p);

Is there any problem with this code?

I explained him that you are trying to assign value to a pointer to whom memory is not allocated.

But the way he reacted, it was like I am wrong. Although I got the job but after that he said Mohit think about this question again. I don't know what he was trying to say. Please let me know is there any problem in my answer?

© Stack Overflow or respective owner

Related posts about c

    Related posts about pointers