I wanted to create a music player (really basic one at best), but I don't really know how to code one. I have searched google a bit and found that
Code:
PlaySound(TEXT("filename.wav"), NULL, SND_FILENAME);
could work (from PlaySound Function (Windows)) but when ever I compile it, it seems to give me errors (using GCC, it says undefined reference to `PlaySoundA@12').
MSDN doesn't give too much information and I don't know exactly what is going wrong.
This is the code I am using currently: (also, i know its REALLY basic, but I can't even get the song to work, so I didn't work on anything else)
Code:
#include <stdio.h>
#include <Windows.h>
char songlist[255][255] = {"song1.wav", "song2.wav", "song3.wav" };
int i = 0, id = 0;
int music(int id)
{
PlaySound(TEXT(songlist[id]), NULL, SND_FILENAME);
return 0;
}
int main(int argc, char** argv)
{
printf("Songs to choose from are:\n");
for (i = 1; songlist[i] != NULL ; i++)
{
printf("%d) %s", i,songlist[i]);
}
printf("\nWhich song would you like to choose?");
scanf("%d", &id);
if (id > i || id < 0)
{
printf("invalid choice\n");
getchar();
main(argc, argv);
}
else
{
music(id);
}
return 0;
}