What is the difference between 0x and '\ x' in C ++?

I know that a hexadecimal number usually has a 0x prefix in C / C ++. For example, 0x5Ameans 90 in decimal. But I saw a code example using the one-shot character c '\x'.

BYTE outputBuffer[index++] = '\x5A'; // instead of 0x5A

Is the value '\x5A'exactly the same as 0x5A?

If so, why is there an alternative hexadecimal notation?

+4
source share
1 answer

For a character, both values ​​are equal.

But only one can be mixed per line with other normal characters. "ABC\x5A"

And only one can be used to initialize a large integral type: long long x = 0x1234567812345678LL;

+7
source

Source: https://habr.com/ru/post/1527156/


All Articles