Search code examples
audiowav

How to play a WAV file using C++/C program?


I want to know how we can play a WAV file stored in my computer using C++/C program. I'm using sndfile.h header file to read a WAV file. So, it's better if I could use the same library to play the WAV file.


Solution

  • Never mind, I solved it myself. I used the following libraries -

    #include<windows.h>
    #include<mmsystem.h>
    #pragma comment( lib, "winmm.lib" )
    

    and used -lwinmm in linker. Then I used PlaySound command.This video can make it clear in case it helps someone - https://www.youtube.com/watch?v=7pTUeSPFhIM