play small sound files through c++

Hey all!

I have a 3-4 sec piece of alarm sound (system failure) and i want to play it through c++ on windows. Im making a console app, and when something fails i want to add the "system failure" sound (yes, like the one on "lost").
I want to add it into a loop. so anywais, how do i do that?
i think this is for windows visual c++ only, or i cant configure it, could someone please show me an example of this?
1
2
3
4
5
6
7
8
9
10
11
#include <windows.h>
#include <mmsystem.h>
#include<iostream>
#pragma comment( lib, "winmm" ) 
using namespace std;
int main(){
	
PlaySound(TEXT("dont2.wav"), NULL, SND_FILENAME);

return 0;
}
Don't use #pragma s as the aren't portable.
To change linker settings ( ie adding a library ) use the IDE project properties, a makefile or the pass your compiler the right arguments
closed account (S6k9GNh0)
A popular solution is to use the SFML library, SDL, etc. libraries. For more defined and better controlled sound, OpenAL is currently the free standard. OpenAL really isn't difficult to use either.
Topic archived. No new replies allowed.