I was coding using on C++ with the compiled MSVC and noticed something:
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
. Use 0x4D
instead of '\x4D'
, and 0x90
instead of '\x90'
:
if ( std::stoi ( "4D", nullptr, 16 ) == 0x4D )
Beep ( 200, 400 );
if ( std::stoi ( "90", nullptr, 16 ) == 0x90 )
Beep ( 200, 400 );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.