Christiano
unread,Feb 12, 2018, 9:44:01 PM2/12/18You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
See the following statement:
std::cout << "\105ba" << std::endl;
In the ascii table 105 octal means 'E', so the result is: "Eba"
I want to do the same thing using hexadecimal escape sequence
std::cout << "\x45ba" << std::endl;
And the result is:
$ CC a.cpp
a.cpp:7:16: error: hex escape sequence out of range
std::cout << "\x45ba" << std::endl;
^~~~~~
1 error generated.
The book C++ Primer Fifth edition - Stanley Lippman - in the page 39 says:
""""" C++ Primer 5th, page 39 """""""""""""""""""""""""""""""""
"We can also write a generalized escape sequence , which is \x followed
by one or more hexadecimal digits or a \ followed be one, two, or three
octal digits. The value represents the numerical value of the character."
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
My question is:
How can I write the sequence \x45 + b + a ("Eba") without the compiler
understanding 'b' and 'a' as hexadecimal characters ?
In Octal this problem doesn't exist, example:
std::cout << "\10510" << std::endl;
will print "E10", that is, '1'+'0' will not be interpreted as octal
characters.