0

Please explain.

char* a = "Coding"; char *b = (++a)+3; cout<<a<<endl; cout<<*a<<endl; cout<<b<<endl; cout<<*b<<endl; output: oding o ng n How this kind of output came?

24th Dec 2016, 1:30 AM
Aniruddh Dubey
Aniruddh Dubey - avatar
2 Respostas
+ 1
We start at the first line. There you assign the address of 'C' in the char array "Coding" to a. In the second line you assign two values. First you increase the pointer of a by 1. Now it points on 'o'. secondly you assign the value of a increased by 3 to b which is now pointing on 'n'. Now we come to your output. cout << a means an output of the char array from its first element a which is now a cout << *a means to output the value a is pointing on which is 'o' cout << b outputs the remaining array from the beginning which is b. cout << *b outputs the value at the address b
24th Dec 2016, 2:42 AM
Andreas K
Andreas K - avatar
0
Is Coding mispelled on purpose?
24th Dec 2016, 2:47 AM
Andreas K
Andreas K - avatar