Click to See Complete Forum and Search --> : System beep in C++


Mandrel
12-14-2000, 01:10 PM
What different functions are available to get a system beep? I did a 'man beep' and that page says to use 'int beep(void)' in curses.h. When I compile using this function, I get an error saying "undefined reference to 'beep' ". I'm guessing it has something to do with the void that is passed in. Is this right? If so, how do I pass in a void?

One more question for ya....I wrote a small life simulation that uses an infinite loop to keep the simulation running. How can I stop the loop by hitting a key on the keyboard, instead of using Control+C to kill it?

Thanks for the help!

hungarian
12-14-2000, 01:22 PM
The alarm is:

cout << "\a\n";

\a represents the system beep in C++



------------------
http://homepages.paradise.net.nz/frankkru

Mandrel
12-14-2000, 01:28 PM
Sweet! That did it. I knew that, but didn't even think about using it....

Any help on the while loop?

Mandrel
12-14-2000, 01:45 PM
By the way, is there any way to change the volume of the system speaker? I'm using an AMD K6-2 450, Epox MB, if that make a difference...

Thanks again...

YaRness
12-14-2000, 02:39 PM
apparently there's a beep.h that lets you do durations and pitches. i'm not sure if it's included in linux or if you have to download, but it's out there somewhere. (http://www.google.com/search?q=beep.h)

------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/
------------------

Phuzon
12-14-2000, 05:03 PM
#include <curses.h>

void main(void) {
beep();
}

save as as beep.c
compile with gcc -obeep beep.c -lcurses