I found some code that i've had for a long time. about 4 years or so. this code used to compile perfectly under turbo c++ 3.0 compiler. But it doesn't under newer compilers. probly cuz of dos.h Neway this should give you an idea on what to do. maybe you can substitute some of those old dos functions for newer functions and make it work. This is a code that i found somewhere online a long time ago. I do not know who wrote it. So the credit goes to whoever wrote it. It is a familiar jingle but i dont know which cuz i can't get the code to compile under msvc. Good luck anyway
#include <dos.h>
#include <conio.h>
void playsound(int note, int duration);
int main()
{
int song[][2]={
392,250,392,375,330,125,330,250,
392,250,392,375,294,125,294,250,
330,250,349,250,392,250,440,250,
494,250,392,750,392,250,392,375,
330,125,330,250,392,250,392,375,
294,125,294,250,587,250,554,250,
587,250,659,250,404,250,587,750,
392,250,659,375,659,125,587,250,
523,250,523,375,494,125,494,250,
523,250,587,250,494,250,440,250,
392,250,523,750,523,250,523,375,
440,125,440,250,523,250,440,250,
392,125,392,250,392,250,440,250,
523,250,392,250,587,250,523,750,
0,0
};
int x=0;
while(song[x++][0])
playsound(song[x][0],song[x][1]);
delay(100);
return 0;
}
void playsound(int note, int duration)
{
do{
sound(note);
delay(duration);
nosound();
}
while(!kbhit());
}
|