+ 23
char *a ="coding"; char *b=(++a)+3; cout << b;???
i don't understand this, can someone give some explanation?
9 Answers
+ 3
you're right saeid, i think it writes cout<<*b;
+ 2
@vikas i'm sure that i get at least one run from this code and the answer was "n" ;)
+ 2
if 'cout<<b' the output is "ng"
but if 'cout<<*b' the output is "n"
+ 2
all these *chars acts as an array the ' *a ' initially indicates/ points the first charactr of the string and as the *a gets incremented the memory address is increased. as like in arrays.
also these are defined in chars so output is also a char not a string so 'n' is the right answer
+ 1
the output is "ng" bcuz you assign the address of n to b. and when you print b then it will print from n to last character of the string i.e. g.
+ 1
hey @nima,
before saying anyone wrong.....first you should prove yourself correct............can you please copy this code and run it on this app sololearn.............you'll get your ans
+ 1
b points to a + 4 implies cout << b prints 'ng'
- 1
the output is "n" because you assigned "a" from second character(++a) to end to "b" and you want print a character in the index "3" from this "oding", that is 'n'
- 1
you're wrong @vikas