How to make the hardware beep sound with c++?
cout << "\a"; In Xcode, After compiling, you have to run the executable by hand to hear the beep.
The Beep function in C is used to make a Beep sound. It generates a tone on the speaker. The function is synchronous, i.e. it waits and doesn't return to its caller function until the sound is finished. It can be very useful during the Debugging process for finding errors.
Sound function produces the sound of a specified frequency. Used for adding music to a C program, try to use some random values in loop, vary delay and enjoy.
\a (alert) Produces an audible or visible alert without changing the active position. I´ve never seen this used in any C code to indicate an error. By the way, I didn´t know that an escape sequence can/could trigger an audible signal on some systems.
Print the special character ASCII BEL
(code 7)
cout << '\a';
Source
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