This function does not work either.. error msg is as follows

beep.cpp: In function ‘int main()’:
beep.cpp:8: error: ‘Beep’ was not declared in this scope
please assist!

#include <windows.h>
#include <iostream.h>

using namespace std;

int main() {

        Beep (100,100);

        return 0;


what compiler are you using? It compiled and linked ok using VC++ 2008 Express.

You can't use iostream.h and using namespace std; at the same time.

commented: Useful post, I did already know it myself, but maybe the others didn't ... +1

In console (Windows) the following code will do the job:

#include <iostream>

using namespace std;

void beep(void);

int main(void)
    return 0;

void beep(void)
    char ascii = 7;
    cout << ascii;

You just have to send the ASCII 7 - code to the screen ...

You just have to send the ASCII 7 - code to the screen ...

But that's just a boring little beep. The Beep( ) function lets you specify frequency and duration - you could make music with it.

As to OP's scope problem, I've no clue. It works for me once the .h is removed from iostream.

The posted code is also working for me (both, without removing the .'h' and with removing the '.h' from the include directives) ...

I'm using the Borland Compiler ...

P.S: Ancient Dragon asked you: Which compiler are you using ?

the beep function is in the 'windows.h' library

Well, it's in winbase.h, but you want to include windows.h to be able to use it.

Also, be aware that Beep(...) can behave differently on different machines. On some machines it will only come from an onboard speaker (if present), on other machines it will come through your audio device (i.e. speakers) if they are attached and through the system speaker if they are not.