Help to skip a process
I'm working on a project that plays a song, but I want the user to have the option to skip the song if they do not want to hear it. The only way that I know to end a process is to hit ctr-c, which of course kills the whole program. The code that I have to start the song is below...
I have searched for hours and cannot find anything that helps. I'm using Dev++. Any help would be appreciated. Thanks in advance.
PlaySound("Daylight.wav", NULL, SND_FILENAME|SND_LOOP);
Look at the options for PlaySound().
In the options for the third argument, there is SND_ASYNC which plays the sound assynchronously, and returns control to your program. All you then need to do is check for termination conditions (eg if the user has hit CTRL-C, if that's what you're using) and call PlaySound() with the first argument NULL - that terminates any playing sound.