Strange beep when using cout

前端 未结 4 1674
北海茫月
北海茫月 2021-01-18 19:41

today when I was working on some code of mine I came across a beeping sound when printing a buffer to the screen. Here\'s the mysterious character that produces the beep: \'

4条回答
  •  不要未来只要你来
    2021-01-18 20:07

    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.

提交回复
热议问题