0

What is the output of the code?😉 Pls explain

char*a ="coding"; char*b=(++a)+3; cout <<*b

5th Oct 2016, 6:55 AM
if u dare challenge me!
if u dare challenge me! - avatar
2 Answers
+ 4
answer: 'n'. a is a pointer to the first value of the string a[0] = 'c'. so (++a) means a[1], which is the value of 'o', then +3 = a[1+3] -> a[4] so now b is a pointer to the memory adress of a[4] when you use cout<<*b; it says give me the value in the location you are pointing which is 'n'. couse a[4] = 'n'.
5th Oct 2016, 7:20 AM
Hector Sulbaran
Hector Sulbaran - avatar
0
thnx
5th Oct 2016, 2:55 PM
if u dare challenge me!
if u dare challenge me! - avatar