how to use sound effect in ur program ?

I will be grateful if someone help me .
How can I insert some sound effect in my C program for for Example:

If(x > 10 )
worning sound ;


something like that








Standard C (or C++) doesn't have any sound functions. You can try printf("\a"); This might give you a beep sound.

If you are using windows you can use Beep function if you include <windows.h> I think. Beep(440, 500); 440 is the frequency of the sound in hertz and 500 is the duration of the sound in milliseconds.

If you are using a different OS or want something more platform independent you need to use an external library like SDL, OpenAL or FMOD.
Last edited on
Tank u so much Peter, I tried ( printf"\a") it works well
eh, you could just beep at different intervals with different frequencies. I split 500ms into 4 increments of 125ms long beeps and made a reasonable tone for a timer I wrote. It turns out that it's pretty nice. ^^
Topic archived. No new replies allowed.