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?
2 Answers
+ 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
0
Is Coding mispelled on purpose?