I try to play sound file using C++ in Ubuntu. I can compile this code in terminal with g++ play.cpp -o play
line. It can be compiled well, but when I execute it with ./play
, it says Failed to play sound: File or data corrupt
. I cannot find where is the problem. Here is my code;
#include <iostream>
#include <stdlib.h>
int main()
{
system("canberra-gtk-play -f cow.wav");
return 0;
}