`outportb' undeclared 怎么回事?

qnbs1 2009-12-23 07:56:05
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>//rand()调用
#include<dos.h>
//#include<time.h>
void sound(unsigned int freq);
int main()
{unsigned int freq;
do
{do
{freq=rand();
} while(freq>1000);

sound(freq);
}
while(!kbhit());
}

void sound(unsigned int freq)
{
unsigned i;
union
{long divisor;
unsigned char c[2];
}count;
unsigned char bits;
count.divisor=119328/freq;
outportb(0x43,0xb6);
outportb(0x42,count.c[0]);
outportb(0x42,count.c[1]);
bits=inportb(0x61);
outportb(0x61,bits|3);
for(i=1;i<20000;i++);
outportb(0x61,bits&0xfc);
}


}

是一个让计算机发声的程序, `outportb' undeclared (first use this function) 未定义?
这个在哪个头文件里有?
...全文
151 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lovesi3344 2010-01-25
  • 打赏
  • 举报
回复
角马不是马
终于又见到你了
好久不见

[Quote=引用 1 楼 do_fork 的回复:]
今年是2009年,不是1989年
[/Quote]
qnbs1 2010-01-25
  • 打赏
  • 举报
回复
v那本书确实老了.呵呵,已放弃
kouwenlong 2009-12-23
  • 打赏
  • 举报
回复
#include<dos.h>
这个头文件在windows不能用吧。
do_fork 2009-12-23
  • 打赏
  • 举报
回复
今年是2009年,不是1989年
用C语言做的DOS界面的串口通信程序 void setPort(int size, char check, int stop){ unsigned char b = 0x00; disable(); switch(size){ case 6:b |= 0x01; break; case 7:b |= 0x02;break; case 8:b |= 0x03; break; } switch(check){ case 'N': case 'n':b &= ~0x08;break; case 'J': case 'j':b |= 0x08; break; case 'O': case 'o':b |= 0x18;break; } switch(stop){ case 1: b &= ~0x04;break; case 2: b |= 0x04;break; } outportb(PORT[PORTNUM] + 3, b); /*register interrupt*/ outportb(PORT[PORTNUM] + 1, 0x01);/*接收中断*/ outportb(PORT[PORTNUM] + 4, 0x0b);/*零MODEM,恒有效状态*/ oldhandle = getvect(INTR[PORTNUM]);/*取得硬中断向量表的中断处理程序*/ setvect(INTR[PORTNUM],newhandle); /*开启IRQx*/ outportb(0x21, inportb(0x21) & INTRENTER[PORTNUM]); enable(); } /* baund:波特率 */ void initCom(int baund){ unsigned char b; disable(); outportb(PORT[PORTNUM] + 3, 0x80);/*设DLAB=1*/ outportb(PORT[PORTNUM] + 1, 0X00);/*高八位设0*/ switch(baund){ case 2400:b = 0x30;break; case 3600:b = 0x20;break; case 4800:b = 0x18;break; case 7200:b = 0x10;break; case 9600:b = 0x0c;break; } outportb(PORT[PORTNUM], b); enable(); } void closeCom(){ disable(); setvect(INTR[PORTNUM],oldhandle); enable(); } void setDefineOpion(){ } void readOpion(){ } int AcceptOrRefuse(){ int index=0; int key = 0; int ret; char str[2][7]={"accpet","refuse"}; while(key!=13) { gotoxy(12,5+index); textcolor(15); printf("%s",str[index]); index=1-index; gotoxy(12,5+index); textcolor(13); printf("%s",str[index]); key=bioskey(0); key=key&0xff; } if (index == 0){ ret = 0; strcpy(sendmsg, "_accept"); strcat(sendmsg, "\0"); sendMessage(); } else { ret = 1; strcpy(sendmsg, "_refuse"); strcat(sendmsg, "\0"); sendMessage();

64,648

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧