This was prompted by some experimenting with C/C++; neither the statement
printf("\a");
nor the statement
cout << "\a";
produce an audible bell sound. How is the \a supposed to function . . .
Although the ASCII BEL control character has a well-defined meaning, its exact interpretation in your console is highly platform dependent. C defines \a
as the escape sequence for the ASCII BEL character found at code 7 and sometimes known as Ctrl+G. In the good old days, this control code allowed the bell of a remote terminal to be rung to alert the remote operator that a message needed attention.
In modern systems, the bell has largely been replaced by other mechanisms. You console window (whether an xterm or similar on *nix or a Console Windows on Windows) now has the responsibility of doing something "sensible" with that control character. It also has the freedom to ignore it completely.
On Windows, you can achieve an audible alert by calling MessageBeep()
, passing 0xffffffff
to get a simple beep noise that uses no system resources, MB_OK
or another MB_ICON*
constant to get one of the system event sounds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With