如何用C语言编一个发出声音的程序?

我在网上找了些程序,编译都没问题,运行时就是听不见声音?如:
#include <dos.h>
void main(void)
{
int i;
for(i=0;i<=1000;i++)
{
sound(i);
delay(1000);
nosound();
}
}

这个唱 多来米法少
#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);
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-09-09
现在windows中,已经不能这样,,,,,,可以使用WIndows API的 Beep函数本回答被网友采纳
第2个回答  2023-10-21
这个唱都热米发馊拉稀都【谢楼上大哥给的范例,改了一下,在main前加了个void】
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
void 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);
}
第3个回答  2017-08-17
可以调用Windows的api
相似回答