为啥我在这个程序上听到哔哔声? [复制]
Posted
技术标签:
【中文标题】为啥我在这个程序上听到哔哔声? [复制]【英文标题】:Why do I hear a beep on this program? [duplicate]为什么我在这个程序上听到哔哔声? [复制] 【发布时间】:2013-07-05 23:47:47 【问题描述】:我在阅读时在一个源上看到了这个char szPrivateKey[]
定义,所以我去检查它是什么,奇怪的是,当程序运行时它会发出声音。这里有复活节彩蛋吗? (使用visual studio 2003/windows编译)
int _tmain(int argc, _TCHAR* argv[])
const unsigned char szPrivateKey[] =
0x30 ,0x82 ,0x04 ,0xBB ,0x02 ,0x01 ,0x00 ,0x30 ,0x0D ,0x06 ,0x09 ,0x2A ,0x86 ,0x48 ,0x86 ,0xF7 ,
0x0D ,0x01 ,0x01 ,0x01 ,0x05 ,0x00 ,0x04 ,0x82 ,0x04 ,0xA5 ,0x30 ,0x82 ,0x04 ,0xA1 ,0x02 ,0x01 ,
0x00 ,0x02 ,0x82 ,0x01 ,0x01 ,0x00 ,0x87 ,0x1F ,0xEC ,0xFD ,0xAF ,0xD2 ,0x2F ,0xAA ,0x4E ,0xC2 ,
0xAD ,0x5A ,0x4C ,0x3A ,0x7A ,0x81 ,0x9E ,0xBA ,0x28 ,0x6A ,0x84 ,0xE9 ,0xB7 ,0xF9 ,0x36 ,0x87 ,
0x56 ,0x16 ,0xC5 ,0xA4 ,0x1D ,0x11 ,0x67 ,0x12 ,0x87 ,0x81 ,0xF5 ,0xFA ,0xF6 ,0x01 ,0xE7 ,0x55 ,
0x83 ,0x4A ,0xAC ,0x40 ,0x4D ,0x2C ,0x90 ,0x62 ,0x77 ,0xFC ,0x73 ,0xF9 ,0x5E ,0x7F ,0x67 ,0x8C ,
0xA7 ,0x94 ,0x32 ,0x28 ,0xDD ,0xEF ,0x91 ,0xE5 ,0x94 ,0xD6 ,0x5C ,0xB5 ,0x63 ,0xC4 ,0x76 ,0x2D ,
0xFF ,0x03 ,0x75 ,0x55 ,0x85 ,0x60 ,0x56 ,0x44 ,0x37 ,0x18 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0x96 ,0x1C ,0x1B ,0x3B ,0xC6 ,0x85 ,
0x92 ,0x88 ,0xAC ,0xC8 ,0xAC ,0x9F ,0x18 ,0x74 ,0x9D ,0x45 ,0xB4 ,0x7B ,0x13 ,0xAB ,0x78 ,0x8D ,
0x8B ,0xB5 ,0x9E ,0x9E ,0xD2 ,0xD7 ,0xF2 ,0x84 ,0x34 ,0xFB ,0x08 ,0xB2 ,0x23 ,0xC7 ,0x0B ,0xF0 ,
0xA9 ,0xCA ,0x17 ,0x1A ,0xA2 ,0x6D ,0x63 ,0xD3 ,0x90 ,0xEF ,0xD1 ,0x62 ,0xE6 ,0x46 ,0x25 ,0x6D ,
0x6D ,0x23 ,0x3B ,0xB0 ,0x65 ,0xEA ,0xE2 ,0x22 ,0x24 ,0xC9 ,0x09 ,0x1B ,0x0D ,0x42 ,0x9D ,0x77 ,
0xE1 ,0x63 ,0xB2 ,0x03 ,0x0D ,0x4A ,0xA2 ,0xFD ,0x2E ,0x2D ,0xCD ,0x4B ,0x9E ,0x63 ,0x91 ,0x0F ,
0x42 ,0xC2 ,0x01 ,0x24 ,0x68 ,0x4C ,0xB5 ,0xA8 ,0x35 ,0xE3 ,0x31 ,0xE8 ,0x86 ,0x32 ,0xB1 ,0xA9 ,
0x4F ,0xBE ,0x23 ,0x3A ,0x3C ,0x0A ,0x5D ,0x26 ,0xBE ,0xA7 ,0x5D ,0xC0 ,0x60 ,0x42 ,0x1D ,;
for( int i =0; i<sizeof(szPrivateKey); i++ )
cout << szPrivateKey[i] << endl;
return 0;
【问题讨论】:
一些角色尖叫(哦,可怕!) 看起来你的程序正试图表达它对你的爱。 如果您继续尝试使用足够随机的字节,您一定会看到拿撒勒耶稣的脸。 如果你很幸运,你会得到耶稣,如果你没有,你会让 Chuck Norris 吃掉你的代码。 希望你把这把钥匙扔掉... 【参考方案1】:字符0x07
是ASCII 响铃字符。支持各不相同,但将其发送到控制台通常会产生单一的哔声。
【讨论】:
【参考方案2】:因为szPrivateKey
- 0x07 或 CTRL-G 中有一个 0x07(在以 0xBA 开头的行),在大多数系统上,它将是一个 BEL
字符,所以它在旧电传打字机上响铃.现代计算机,甚至 30 年历史的终端,都没有机械铃(打字机也没有,如果你现在能找到的话),所以他们用哔声代替。
在 C 和 C++ 中,您可以使用 "\a"
在字符串中创建 BEL 字符(并且它在不使用 ASCII 的系统上也可以正常工作,它会在非 ASCII 系统中生成任何对应的字符)。
顺便说一句,这不是“复活节彩蛋”,它是打印一些不是真正“文本”的东西的结果,因此不应与cout
一起显示。您可以使用type myfile.dat
或类似的东西获得相同的结果(假设myfile.dat
是一个二进制文件并且其中有一个0x07 字节)。
【讨论】:
在旧的 ASR33 TTY 上打印随机二进制一直是一场精彩的表演——打字轮会剧烈旋转,铃声会响起,压板会继续前进。 (尽管令人惊讶的是,随机二进制中的回车很少——它往往会跑到右边距并坐在那里,在页面右侧形成污迹。) 当有人不小心在我们学校和早期工作场所的大型打印机上打印二进制文件时,总是很“有趣”——是的,那里的换行和换页似乎比马车更多由于某种原因返回/【参考方案3】:这是 ascii 表的前 10 个条目:
Oct Dec Hex Char
---------------------------------------------
000 0 00 NUL '\0'
001 1 01 SOH (start of heading)
002 2 02 STX (start of text)
003 3 03 ETX (end of text)
004 4 04 EOT (end of transmission)
005 5 05 ENQ (enquiry)
006 6 06 ACK (acknowledge)
007 7 07 BEL '\a' (bell)
010 8 08 BS '\b' (backspace)
011 9 09 HT '\t' (horizontal tab)
注意 ascii 代码 7 ,如果您向其写入该字符,许多终端都会发出声音。
【讨论】:
哦,有趣,该死,使用 C++ 快 3 年了,仍然有惊喜!只要 S.O 允许,就会接受 @Viniyo Shouta:这与 C++ 无关。这是关于特定输出设备的特定属性。【参考方案4】:\a
,也称为BEL
,在大多数机器中具有0x07
。
来自 C++11 2.14.3
提醒 BEL \a
从 C99 5.2.2
\a(alert) 在不改变活动位置的情况下产生声音或可见警报。
【讨论】:
0x0B
是垂直制表符。以上是关于为啥我在这个程序上听到哔哔声? [复制]的主要内容,如果未能解决你的问题,请参考以下文章