C++ playsound()
Ok. I've been attempting to include sound in my project for a certain period of time. Fortuantly, I came across this:
#include <MMSystem.h>
int main() { char* WAV = "c:\\ratm-bulletinthehead"; sndPlaySound(WAV, SND_ASYNC); return 0; }
However, the compiler states that I have errors like these:
C:\DEV-C_~1\Include\MMSystem.h:896: syntax error before `;'
898 c:\dev-c_~1\include\mmsystem.h `CALLBACK' was not declared in this scope
Line 898? It say's the same thing about 14 times except with "DWORD" not declared and such. I don't know if this is because a code like this is directly related to VC++ because I am yielding way to many errors. So, I came across this:
#include <windows.h> #include <mmsystem.h> #pragma comment(lib, "winmm.lib")
int main() { PlaySound("ratm-bulletinthehead.wav", NULL, SND_FILENAME | SND_SYNC); return 0; }
Well, I got all the necessary headers I would suppose. And it compiles fine, but it can't execute ;S does anyone know a solution e.g change this to that or you just plain can't do it lol.
Well, this works..
#include <windows.h>
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")
int main(int argc, char *argv[])
{
PlaySound("C:\\test.wav", NULL, SND_FILENAME | SND_SYNC);
return 0;
}
so I'm going to guess that you forgot to specify the full path to your .wav file. ;)