Reputation: 19
I am trying to figure out how to play sounds when making a program in c. I have been searching all over the internet and I learned i can use Play sound. I followed the instructions I saw by adding certain libraries to my code and adding a linker.
Code:
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <MMSystem.h>
int main(void)
{
PlaySound("C:\\Users\\chris\\Downloads\\pokemon-red-and-blue-music-opening-theme.wav", NULL, SND_FILENAME | SND_ASYNC);
return 0;
}
I am using devc++ as my IDE to run my c program. The linker i used was -lwinmm. Whenever i compile and run my code, the program compiles and runs but it does not play any music for some reason. I made sure to copy the paths of my wav file but it is still not working. I would like to know what am i doing wrong.
Upvotes: 0
Views: 68