假设我有以下内容:
int i = 'abc';
如果有办法将字符串更改为多字 rune 字,如下所示
char* str="abc";
int j = ?
(我们也想设置 int j= 'abc'
)。
但是如何用字符串做到这一点呢?
最佳答案
C99 6.4.4.4/10:
The value of an integer character constant containing more than one character (e.g., 'ab'), or containing a character or escape sequence that does not map to a single-byte execution character, is implementation-defined."
C++11 2.14.3/1:
A multicharacter literal has type int and implementation-defined value.
因此,在不知道您的具体实现是做什么的情况下,您无法重现相同的结果。一旦您知道它的作用,您应该能够毫无问题地自行计算 j
。
关于c++ - 如何在 C++ 中将字符串更改为多字 rune 字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28160535/