读书人

为什么提示这样的异常

发布时间: 2013-09-15 19:58:13 作者: rapoo

为什么提示这样的错误
#include <stdio.h>
#include <dos.h>

void main()
{
unsigned int freq; /* 指定的频率 */

do {
printf("Enter frequency: "); /* 显示键入频率的提示信息 */
scanf("%d",&freq); /* 接受键入的频率 */
if ( freq) { /* 频率不应为0 */
sound(freq); /* 开始发指定频率的声音 */
delay(1000); /* 延时一秒钟 */
nosound(); /* 关闭声音 */
}
} while ( freq ); /* 如指定的频率为0,则结束 */
}

F:\C++\sound\sound.cpp(12) : error C2065: 'sound' : undeclared identifier
F:\C++\sound\sound.cpp(13) : error C2065: 'delay' : undeclared identifier
F:\C++\sound\sound.cpp(14) : error C2065: 'nosound' : undeclared identifier
[解决办法]
sound改为Beep
delay改为Sleep
[解决办法]
用VirtualBox安装DOS6.22虚拟机,在DOS下安装Turbo C2.0,才能编译和运行你的程序。

引用:

#include <stdio.h>
#include <dos.h>

void main()
{
unsigned int freq; /* 指定的频率 */

do {
printf("Enter frequency: "); /* 显示键入频率的提示信息 */
scanf("%d",&freq); /* 接受键入的频率 */
if ( freq) { /* 频率不应为0 */
sound(freq); /* 开始发指定频率的声音 */
delay(1000); /* 延时一秒钟 */
nosound(); /* 关闭声音 */
}
} while ( freq ); /* 如指定的频率为0,则结束 */
}

F:\C++\sound\sound.cpp(12) : error C2065: 'sound' : undeclared identifier
F:\C++\sound\sound.cpp(13) : error C2065: 'delay' : undeclared identifier
F:\C++\sound\sound.cpp(14) : error C2065: 'nosound' : undeclared identifier

读书人网 >C++

热点推荐