I'm following a book and currently learning about pointers and such however when i run this code i also get a wierd error sound. It's kinda cool that it does but i don't know why it's called and the book didn't say anything about (possibly cause the book is decently old now). The sound occurs when i call for 'ErrorMessage'. Is that some kind of easter egg cause i don't remember including any audio libaries?
#include <iostream>
ErrorMessage(char* msg)
{
std::cout << "\aError:" << msg << std::endl;
}
int main()
{
char* ep = "Invalid Input";
ErrorMessage(ep);
char msg[] = "Disk Failure";
ErrorMessage(msg);
ErrorMessage("Timeout");
}
Its because of
std::cout << "\aError:" << msg << std::endl;
Notice that \a.
\a is an escape character which is audible alert which is generating that sound
You have used an escape sequence when you've typed that backslash in your std::cout literal.
\a is a very old-fashioned way of sending a beep signal to your terminal (called the BEL character), assuming your console (i.e. the thing that you used to launch your application) supports beeping.
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