0

Can anyone explain this program

char * a="Coding"; char *b=(++a)+1+1; printf("%c",*b); Ans = i please anyone explain here. Thanks in advance.

27th Oct 2018, 10:45 AM
Pavithran
Pavithran - avatar
2 Antworten
+ 3
adding 1 to pointer results in change of memory address by sizeof(base class or data type) so ++a on char *a causes char *a to point to next memory address i.e. address of letter o. Now doing that again two time as +1 causes to move pointer to d and then to i. so i is printed
27th Oct 2018, 11:35 AM
Megatron
Megatron - avatar
0
thanks a lot sir.
27th Oct 2018, 11:45 AM
Pavithran
Pavithran - avatar