c语言中,beep是个什么函数?
2个回答
展开全部
是发声函数,运行后通过主板喇叭唱出旋律,可以试试下面:
TC 试:
#include<dos.h>
#include<conio.h>
#include<stdlib.h>
/* this founction plays sound until hit any key */
void mysound()
{
long freq ;
while(!kbhit()){/* while no keyboard hit, play sound */
for(freq=200L;freq<2000L;freq+=200L){
sound(freq);/*play freq sound*/
delay(200);/*delay 200ms*/
}
}
nosound();/* stop playing */
}
void main()
{
mysound() ;
}
---------------
VC++ 试:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
main()
{
Beep(523,500);
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);
Sleep(500);
Beep(523,500);
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);
}
------
wintc 试验上两个。
TC 试:
#include<dos.h>
#include<conio.h>
#include<stdlib.h>
/* this founction plays sound until hit any key */
void mysound()
{
long freq ;
while(!kbhit()){/* while no keyboard hit, play sound */
for(freq=200L;freq<2000L;freq+=200L){
sound(freq);/*play freq sound*/
delay(200);/*delay 200ms*/
}
}
nosound();/* stop playing */
}
void main()
{
mysound() ;
}
---------------
VC++ 试:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
main()
{
Beep(523,500);
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);
Sleep(500);
Beep(523,500);
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);
}
------
wintc 试验上两个。
更多追问追答
追问
厉害!真有意思啊,也就是说这是个控制发声的函数了吧 他必须要用#include
作为程序的开始对吧? 还有 Sleep(500); 是延时500毫秒吗?delaynms(100)是什么意思?
追答
(⊙v⊙)嗯
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询