Transfer from http://blog.csdn.net/todd911/article/details/8851475
The book has the following description:
\DDD DDD denotes an octal number, which is the character represented by the given octal value.
\XDDD is similar to the previous example, except that the octal number is replaced by a 16 binary number.
Note that any hexadecimal number may be included in the \xddd sequence, but the result is undefined if the size of the resulting value exceeds the range of characters represented.
Problem:
Why the \XDDD, that \ddd, if more than the expression of the range of characters, what will happen.
So the following tests were done:
[CPP]View Plaincopy
- #include <stdio.h>
- int main (void) {
- printf ("\x123456\n");
- return 0;
- }
The following errors are reported after compiling:
printf.c:in function ' main ':
Printf.c:4:9:warning:hex escape sequence out of range [enabled by default]
Post-run output:
V
Guessing that the computer sees \x1234 as a whole, because it exceeds 255 and cannot be displayed, 16 binary 56 is exactly v in ASCII.
Then test the following:
[CPP]View Plaincopy
- #include <stdio.h>
- int main (void) {
- printf ("\123456\n");
- return 0;
- }
Compile without error
After running the result is:
S456
Where 8 binary 123 is exactly the s,456 in ASCII is not translated.
The visible computer is not the same for 8-and 16-binary escape character processing.
\DDD and \XDDD escape sequences