Learners Only
Friday 23 September 2011
Predict the output or error(s) for the following:
void main()
{
int const * p=5;
printf(“%d”,++(*p));
}
Answer:
Compiler error: Cannot modify a constant value.
Explanation
:
p is a pointer to a “constant integer”. But we tried to change the value of the “constant integer”.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment