number of digits in a hex escape code in C/C++

后端 未结 3 824
挽巷
挽巷 2021-01-07 23:10

I\'m having a dispute with a colleague of mine. She says that the following:

char* a = \"\\x000aaxz\";

will/can be seen by the compiler as

3条回答
  •  遥遥无期
    2021-01-07 23:49

    well, for that matter, hex escape sequence ends at a non hex character, e.g \x0abc9k is 0abc9 in hex and then 'k' so in order to end a hex sequence, you will have to use double quotes twice at the end of it e.g. \x0ab""c9k , which takes only 0ab as hex

    or alternately you could use octal escape sequence as there is limit to the numbers in octal escape sequence so there be maximum only three octal digits in it.. e.g. \o1234 is 123 in octal and then '4'

    So, yes, she is right.

提交回复
热议问题