#include <stdio.h>
int main(void)
{
char s[] = {'a','b','c','\n','c','\0'};
char *p;
p=&s[3];
printf("%d\t",++*p++);
printf("%d",*p);
return 0;
}
output: 11 99
Please explain the output. Why there is an increment in the address?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The only thing I see that could possibly be confusing is
Postincrement has higher precedence than the dereference operator, so fully parenthesized it looks like
Which postincrements
p, dereferences the original value ofpto get achar, then preincrements the value of thechar, and then the new value gets printed byprintfas an integer.So both
pand whatpis pointing at get incremented.