MinusMinus

Hi.
having a definition:
char *s="74\11203";

what does
cout << s-- << endl;
do?Thanks in advance!
The code

cout << s-- << endl;

has undefined behaviour because a pointer shall not point beyond the first element of an array.

As for "what does it do" the statement outputs the string literal "74\11203" and decrements the pointer that results in undefined behaviour.
Last edited on
Decrementing the pointer doesn't result in undefined behavior. Thinking of iterators, perhaps? If one were to dereference the decremented pointer, however...
Topic archived. No new replies allowed.