首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

为什么提示这样的异常

2013-09-15 
为什么提示这样的错误#include stdio.h#include dos.hvoid main(){unsigned int freq/*指定的频率*/d

为什么提示这样的错误
#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

热点排行