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 <dos.h>
#include <conio.h>

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; 
}

Edited 3 Years Ago by pyTony: fixed formatting

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

Comments
Nice attitude: I don't know what I'm doing - do it for me. Now!

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!

//#include <dos.h>
//#include <conio.h>

#include <cstdlib>     // system()
#include <iostream>    // access to stdio.h
#include <windows.h>   // 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; 
}

Next time ask a little nicer!!!!!

This question has already been answered. Start a new discussion instead.