Placing \ a in the output stream makes no sound

This was caused by some experiments with C / C ++; no statement

printf("\a");

and statement

cout << "\a";

will make a sound call. How should \ a.,.

+3
source share
5 answers

Although the BSC ASCII control character has a clearly defined meaning, its exact interpretation in the console is very platform dependent. C defines it \aas an escape sequence for the BEL ASCII character found in code 7 and sometimes called Ctrl + G. In the good old days, this control code used to ring the bell of a remote terminal to warn the remote operator about the need for attention to the message.

. ( xterm * nix Windows Windows) , - "" . .

Windows , MessageBeep(), 0xffffffff, , , MB_OK MB_ICON*, .

+7

. , , .

+2

aplay (GNU/Linux ..):

#include <cstdlib>

int main(int argc, char* argv[])
{
    system("yes \"ZaaZa\" | aplay -c 2"); // stop this with ctrl-c
}

- ( , . -f) aplay. man aplay .

0

. , Windows , Linux . , , aplay.

0

The terminal software assigned STDOUT, decides what to do with the symbol \a. You can try using other terminal software. Or delve into the settings of your terminal. Perhaps there is a switch to turn on / off the sound of the ringer.

0
source

Source: https://habr.com/ru/post/1763515/


All Articles