How to write an unsigned short int literal?

后端 未结 9 1394
慢半拍i
慢半拍i 2021-01-07 15:53

42 as unsigned int is well defined as \"42U\".

unsigned int foo = 42U; // yeah!

How can I write \"23\" so that it is clear it is an

9条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-07 16:37

    Unfortunately, the only method defined for this is

    One or two characters in single quotes ('), preceded by the letter L

    According to http://cpp.comsci.us/etymology/literals.html

    Which means you would have to represent your number as an ASCII escape sequence:

    unsigned short bar = L'\x17';
    

提交回复
热议问题