Reputation: 371
I am a high school student working on learning some C++ on the side of school. I am currently looking into playing sounds in C++ programs. I am trying to use the "PlaySound()" function to do so. I have looked at the MSDN page for this function, as well as looking on Stack Exchange, and watching a video. Unfortunately, when I compile this code I am met with the default windows error sound. I would love some help figuring out what is going wrong with this program.
#include "stdafx.h"
#include <iostream>
#include <windows.h>
using namespace std;
int main() {
PlaySound(TEXT("bird.wav"), NULL, SND_FILENAME);
return 0;
}
Thanks in advance!
Upvotes: 1
Views: 2653
Reputation: 371
The problem was that bird.wav was not in the Visual Studio project file. I moved it there and the sound played correctly.
Upvotes: 1