#include unistd.h // 头文件
成都创新互联公司网站建设服务商,为中小企业提供成都网站设计、网站建设服务,网站设计,成都网站托管等一站式综合服务型公司,专业打造企业形象网站,让您在众多竞争对手中脱颖而出成都创新互联公司。
int usleep(useconds_t usec); // 函数原型
usec -- 毫秒。整数。最大允许值:小于 1000000
返回 0 -- 表示调用执行成功,1 -- 失败。
是发声函数,运行后通过主板喇叭唱出旋律,可以试试下面:
TC 试:
#includedos.h
#includeconio.h
#includestdlib.h
/* this founction plays sound until hit any key */
void mysound()
{
long freq ;
while(!kbhit()){/* while no keyboard hit, play sound */
for(freq=200L;freq2000L;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 试验上两个。
用 Beep 函数,参数1是频率,参数2是时间长度。
下面唱 多来米发少啦西多......
MS VC++ 6.0 编译器
#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);
Beep(880,500);
Beep(980,500);
Beep(1060,500);
Sleep(500);
Beep(523,500);
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);
}
是发声函数,运行后通过主板喇叭唱出旋律,可以试试下面:
TC 试:
#includedos.h
#includeconio.h
#includestdlib.h
/* this founction plays sound until hit any key */
void mysound()
{
long freq ;
while(!kbhit()){/* while no keyboard hit, play sound */
for(freq=200L;freq2000L;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 试验上两个。