how to make a console program make noise

I need to know how to make a console program make noise. Like a beep beep
in different tones. Dose eny budy have an exampol?
1
2
3
4
5
6
7
#include<windows.h>

int main()
{
    Beep(1000, 2000);// 1000 herts for 2000 ms
    return 0;
}


Does that work?

Edit: No need for #include<iostream>, duh.
Last edited on
closed account (3hM2Nwbp)
If I recall, the Beep function doesn't work in Vista, Server 2008, and potentially others because Microsoft removed the feature.
I will try that. thanks!
It werked! thanks browni3141.
here is a program that I made with what you gave me.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<iostream>
#include<windows.h>
#include <conio.h>

int main()
{
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute( handle, 6000 );
	std::cout<< "this program makes crazy noise" << std::endl;
	_getch();
	std::cout << "your mind is being minepulated!" <<std::endl;
    Beep(6000, 9000);
    Beep(658, 100);
    Beep(425, 100);
    Beep(412, 100);
    Beep(425, 100);
    Beep(456, 100);
    Beep(213, 100);
    Beep(654, 100);
    Beep(245, 100);
    Beep(243, 100);
    Beep(452, 100);
    Beep(457, 100);
    Beep(45, 100);
    Beep(54, 100);
    Beep(78, 100);
    Beep(87, 100);
    Beep(89, 2100);
    Beep(98, 100);
    Beep(789, 100);
    Beep(987, 100);
    Beep(456, 100);
    Beep(85, 100);
    Beep(95, 100);
    Beep(45, 100);
    Beep(54, 4100);
    Beep(45, 100);
    Beep(456, 100);
    Beep(745, 100);
    Beep(524, 100);
    Beep(4521, 100);
    
    return 0;
}
interesting... I should stuff into one of my programs and make people think that they are in Star Trek or some other scifi thing with beeping computers.
Thats cool!
Topic archived. No new replies allowed.