0

char array question

char*a = "Coding"; char*b = (++a) + 3; cout << *b // output is n How did we get to the letter n? n is the 5th letter / element in the char array. ++a is equivalent to a=a+1. So char*b = (++a) + 3 is equivalent to char*b = a+4. Does this 4 represent the element number?

25th Jul 2020, 9:29 AM
Solus
Solus - avatar
1 Respuesta
0
"Coding" | a ++a "Coding" | a b = a + 3; "Coding" | | a b Indexes and pointers start from 0
4th Aug 2020, 7:50 AM
Gloginja
Gloginja - avatar