Strange beep when using cout

喜欢而已 提交于 2019-12-01 18:07:25

In ASCII the character 7 is the "bell" character that signals to the terminal that it should beep.

EDIT: To answer your followup question, it's really just for historical reasons. The old teletype terminals needed a way to alert the operator of an incoming message so a bell was used. The bell character told the terminal to ring the bell rather than print a character.

Modern terminal emulators do essentially the same thing, although they usually have an option to replace the audible bell with a visual one.

0x7 is the ASCII character that produces a 'bleep' sound. It is a non-printable character. Here is a full list of the ASCII characters and their codes: http://www.asciitable.com/

Edit: The sound can be used for a veritable melange of things. However you cannot really produce other effects by sending other pieces of data through. In the table in the link above anything on the list below 0x20 (32 decimal) is a non-printable character. They can have different effects depending on where the data is actually output.

Basically you could just write a loop to output 0-(whatever number you wish to stop at) to experiment and see what you can get.

char 7 is the ASCII code for BELL. Writing this character to the console causes the computer to emit a beep. It is perfectly normal.

chat 7 is actually a "beep" character and not a screen character. Although sometimes documentation may show a character, it's generally not something you can render visually.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!