Hello, I am making my way through c++ primer (Lippman) and I have found the examples/exercise so far quite good at reinforcing the topics described.
In the escape sequences section, it talks about using hex (\x) or oct escape values to represent any character. The uses of this might be fairly limited, but I want to understand something about printing characters after a hex escape sequence -
std::cout << "Hello \x4d" << std::endl; \\ 4d in hex is 'M'
std::cout << "Hello \x4dum" << std::endl;
std::cout << "Hello \x4dad << std::endl;
error C2022: '19885' : too big for character |
I understand that hexadecimal escape sequences have no length limit and terminate at the first character that is not a valid hexadecimal digit. But what about when the characters happen to be a valid hex digits?
I can see no way of printing the text literals "ad" after the hex escape sequence apart from
std::cout << "Hello \x4d" "ad" << std::endl;
How would you print "Hello Mad" with the "M" represented as hex, and "ad" as a string literal? (without having it in separate double quotes?) Or is that simply what you need to do in this situtation?
I tried putting in a null character in between ie "Hello \x4d\0ad" but that did not work.
My platform is windows, and my compiler is VS 2008. Thanks.