954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

siren.c won't compile , what's wrong with this code?

hey everyone am trying to generate a beeping sound on my pc using the 'sound' function , the problem is i am getting errors (5 to be exact ) when i compile this program , please someone point out the error on this code , thanx :) below is the code-


#include
#include

int main()


{
unsigned frequency;
do
{
for (frequency = 500; frequency <= 1000; frequency += 50)
{
sound(frequency);
delay(50);
}
for (frequency = 1000; frequency >= 500; frequency -= 50)
{
sound(frequency);
delay(50);
}
}
while (! kbhit());
nosound();


system("PAUSE");
return 0;
}

nico
Newbie Poster
16 posts since Nov 2004
Reputation Points: 10
Solved Threads: 0
 

Looks like very old Borland code. What compiler are you using?

vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

am actually using dev c++ , and it took alot for me to come up with the code :( are you gonna help or what ?

nico
Newbie Poster
16 posts since Nov 2004
Reputation Points: 10
Solved Threads: 0
 

I admittedly have better things to do than to fugg around with old Borland code. This however works with the Dev-C++ compiler. I commented out the Turbo gibberish!
[php]//#include
//#include

#include // system()
#include // access to stdio.h
#include // Beep()

#define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define ESC 27 // escape key

int main()
{
unsigned frequency;

printf("Keep hitting the escape key to stop ...");
do
{
for (frequency = 500; frequency <= 1000; frequency += 50)
{
Beep(frequency,50);
//sound(frequency);
//delay(50);
}
for (frequency = 1000; frequency >= 500; frequency -= 50)
{
Beep(frequency,50);
//sound(frequency);
//delay(50);
}
} while(!KEY_DOWN(ESC));
//while (! kbhit());
//nosound();

system("PAUSE");
return 0;
}
[/php]
Next time ask a little nicer!!!!!

vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You