How can I use sound and nosound function in code blocks

时间:2016-05-26 20:42:10

标签: c codeblocks

I have used sound and no sound function in turbo C++, but I cannot get it to work in code blocks compiler. Program:

 int main() 
 {
     sound();
     delay();
     nosound();
     return 0;
 }  

I have added definition for delay and it's working in other programs. When I am compiling this code I am getting error as ::undefined reference to sound and no sound.

How can I make this work? Or is there a different solution I should use?

2 个答案:

答案 0 :(得分:0)

  1. 您可以使用" Beep"在windows.h头文件中的函数。 在Beep功能中,您必须提供2个参数,第一个是频率,第二个是持续时间(毫秒)。

  2. 你可以' \ a'它发出警报声,' \ a'应该放在printf。

答案 1 :(得分:-1)

I'm doing this right now! But i'm using C, dunno if for C++ is the same.

The only thing i know is that you have to include the library dos.h to make it work.

the function is Beep(soundfrequency,delay); give it a try with Beep(2000,2000);

Good luck :)