\DDD and \XDDD escape sequences

Source: Internet
Author: User

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
    1. #include <stdio.h>
    2. int main (void) {
    3. printf ("\x123456\n");
    4. return 0;
    5. }

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
    1. #include <stdio.h>
    2. int main (void) {
    3. printf ("\123456\n");
    4. return 0;
    5. }

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.