[英]Error Found on std::stoi comparison byte 0x90
I was coding using on C++ with the compiled MSVC and noticed something:我在 C++ 上使用已编译的 MSVC 进行编码,并注意到一些事情:
When I Write some stuff like:当我写一些类似的东西时:
if ( std::stoi ( "4D", nullptr, 16 ) == '\x4D' )
Beep ( 200, 400 );
I can hear the Beep, but when I write something like:我可以听到哔哔声,但是当我写下类似的内容时:
if ( std::stoi ( "90", nullptr, 16 ) == '\x90' )
Beep ( 200, 400 );
The comparison doesn't activate the Beep.比较不会激活哔声。
I Searched in many places but didn't find any way to resolve this.我搜索了很多地方,但没有找到解决此问题的任何方法。
stoi()
returns an int
, not a char
. stoi()
返回一个int
,而不是一个char
。 Use 0x4D
instead of '\x4D'
, and 0x90
instead of '\x90'
:使用0x4D
代替'\x4D'
,使用0x90
代替 '\x90 '\x90'
:
if ( std::stoi ( "4D", nullptr, 16 ) == 0x4D )
Beep ( 200, 400 );
if ( std::stoi ( "90", nullptr, 16 ) == 0x90 )
Beep ( 200, 400 );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.