+ 2

What is the output?

When doing challenges I get the question where there's a char pointer p with multiple letters asigned to it and then I get to cout an incremented value of it. I can never get the answer right. I've tried compiling it but I get errors. Could anyone give me an example of the code and what it outputs?

24th Nov 2016, 11:03 PM
Zablas
Zablas - avatar
3 odpowiedzi
+ 3
already know it. "a" is the output. The pointer is equal to the first letter. Adding anything to it moves it to other letters that much. Trying to output it without the * makes it ouput the remainig letters from the one the pointer outputs with the * (including it) and without the previous ones
27th Nov 2016, 12:29 AM
Zablas
Zablas - avatar
+ 2
char *p = "abcde"; cout << *p++;
25th Nov 2016, 1:46 PM
Zablas
Zablas - avatar
0
If you post your code, sure thing (;
24th Nov 2016, 11:14 PM
Johannes Weitnauer
Johannes Weitnauer - avatar