Champa
Champa

Reputation: 615

Making it beep in c++

I've recently picked up C++ and I am using a Mac with Xcode to start learning.

One of the problems I am having is making it BEEP!!

I know there is a lot of StackOverflow questions for this and the most popular seems to be std::cout << "\007"

#include < iostream >

int main() {
    std::cout << "\007";
    return 0;
}

Is there something I am missing?

Upvotes: 0

Views: 374

Answers (1)

SegFault
SegFault

Reputation: 2546

Try cout << '\a' << flush; instead. You can make a system call like system("say beep"); but this is very OS dependent and will not work on all machines.

Upvotes: 3

Related Questions