C语言函数--H
函数名: harderr
功 能: 建立一个硬件错误处理程序
用 法: void harderr(int (*fptr)());
程序例:
/*This program will trap disk errors and prompt
the user for action. Try running it with no
disk in drive A: to invoke its functions.*/
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#define IGNORE 0
#define RETRY 1
#define ABORT 2
int buf[500];
/*define the error messages for trapping disk problems*/
static char *err_msg[] = {
"write protect",
"unknown unit",
"drive not ready",
"unknown command",
"data error (CRC)",
"bad request",
"seek error",
"unknown media type",
"sector not found",
"printer out of paper",
"write fault",
"read fault",
"general failure",
"reserved",
"reserved",
"invalid disk change"
};
error_win(char *msg)
{
int retval;
cputs(msg);
/*prompt for user to press a key to abort, retry, ignore*/
while(1)
{
retval= getch();
if (retval == 'a' || retval == 'A')
{
retval = ABORT;
break;
}
if (retval == 'r' || retval == 'R')
{
retval = RETRY;
break;
}
if (retval == 'i' || retval == 'I')
{
retval = IGNORE;
break;
}
}
return(retval);
}
/*pragma warn -par reduces warnings which occur
due to the non use of the parameters errval,
bp and si to the handler.*/
#pragma warn -par
int handler(int errval,int ax,int bp,int si)
{
static char msg[80];
unsigned di;
int drive;
int errorno;
di= _DI;
/*if this is not a disk error then it was
another device having trouble*/
if (ax < 0)
{
/* report the error */
error_win("Device error");
/* and return to the program directly requesting abort */
hardretn(ABORT);
}
/* otherwise it was a disk error */
drive = ax & 0x00FF;
errorno = di & 0x00FF;
/* report which error it was */
sprintf(msg, "Error: %s on drive %c\r\nA)bort, R)etry, I)gnore: ",
err_msg[errorno], 'A' + drive);
/*
return to the program via dos interrupt 0x23 with abort, retry,
or ignore as input by the user.
*/
hardresume(error_win(msg));
return ABORT;
}
#pragma warn +par
int main(void)
{
/*
install our handler on the hardware problem interrupt
*/
harderr(handler);
clrscr();
printf("Make sure there is no disk in drive A:\n");
printf("Press any key ....\n");
getch();
printf("Trying to access drive A:\n");
printf("fopen returned %p\n",fopen("A:temp.dat", "w"));
return 0;
}
函数名: hardresume
功 能: 硬件错误处理函数
用 法: void hardresume(int rescode);
程序例:
/* This program will trap disk errors and prompt the user for action. */
/* Try running it with no disk in drive A: to invoke its functions */
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#define IGNORE 0
#define RETRY 1
#define ABORT 2
int buf[500];
/* define the error messages for trapping disk problems */
static char *err_msg[] = {
"write protect",
"unknown unit",
"drive not ready",
"unknown command",
"data error (CRC)",
"bad request",
"seek error",
"unknown media type",
"sector not found",
"printer out of paper",
"write fault",
"read fault",
"general failure",
"reserved",
"reserved",
"invalid disk change"
};
error_win(char *msg)
{
int retval;
cputs(msg);
/* prompt for user to press a key to abort, retry, ignore */
while(1)
{
retval= getch();
if (retval == 'a' || retval == 'A')
{
retval = ABORT;
break;
}
if (retval == 'r' || retval == 'R')
{
retval = RETRY;
break;
}
if (retval == 'i' || retval == 'I')
{
retval = IGNORE;
break;
}
}
return(retval);
}
/* pragma warn -par reduces warnings which occur due to the non use */
/* of the parameters errval, bp and si to the handler. */
#pragma warn -par
int handler(int errval,int ax,int bp,int si)
{
static char msg[80];
unsigned di;
int drive;
int errorno;
di= _DI;
/* if this is not a disk error then it was another device having trouble */
if (ax < 0)
{
/* report the error */
error_win("Device error");
/* and return to the program directly
requesting abort */
hardretn(ABORT);
}
/* otherwise it was a disk error */
drive = ax & 0x00FF;
errorno = di & 0x00FF;
/* report which error it was */
sprintf(msg, "Error: %s on drive %c\r\nA)bort, R)etry, I)gnore: ",
err_msg[errorno], 'A' + drive);
/* return to the program via dos interrupt 0x23 with abort, retry */
/* or ignore as input by the user. */
hardresume(error_win(msg));
return ABORT;
}
#pragma warn +par
int main(void)
{
/* install our handler on the hardware problem interrupt */
harderr(handler);
clrscr();
printf("Make sure there is no disk in drive A:\n");
printf("Press any key ....\n");
getch();
printf("Trying to access drive A:\n");
printf("fopen returned %p\n",fopen("A:temp.dat", "w"));
return 0;
}
函数名: highvideo
功 能: 选择高亮度文本字符
用 法: void highvideo(void);
程序例:
#include <conio.h>
int main(void)
{
clrscr();
lowvideo();
cprintf("Low Intensity text\r\n");
highvideo();
gotoxy(1,2);
cprintf("High Intensity Text\r\n");
return 0;
}
函数名: hypot
功 能: 计算直角三角形的斜边长
用 法: double hypot(double x, double y);
程序例:
#include <stdio.h>
#include <math.h>
int main(void)
{
double result;
double x = 3.0;
double y = 4.0;
result = hypot(x, y);
printf("The hypotenuse is: %lf\n", result);
return 0;
}
书画小说软件 制作更满意的读、更舒心的写、更轻松的公布
最全古典小说网 由本软件公布所得
C语言函数--H的更多相关文章
- 从linux0.11中起动部分代码看汇编调用c语言函数
上一篇分析了c语言的函数调用栈情况,知道了c语言的函数调用机制后,我们来看一下,linux0.11中起动部分的代码是如何从汇编跳入c语言函数的.在LINUX 0.11中的head.s文件中会看到如下一 ...
- C语言(函数)学习之strstr strcasestr
C语言(函数)学习之[strstr]&[strcasestr]一.strstr函数使用[1]函数原型char*strstr(constchar*haystack,constchar*needl ...
- C语言函数sscanf()的用法
从文件读取数据是一件很麻烦的事,所幸有sscanf()函数. C语言函数sscanf()的用法 sscanf() - 从一个字符串中读进与指定格式相符的数据. 函数原型: int sscanf( st ...
- 不可或缺 Windows Native (6) - C 语言: 函数
[源码下载] 不可或缺 Windows Native (6) - C 语言: 函数 作者:webabcd 介绍不可或缺 Windows Native 之 C 语言 函数 示例cFunction.h # ...
- C语言函数指针基础
本文写的非常详细,因为我想为初学者建立一个意识模型,来帮助他们理解函数指针的语法和基础.如果你不讨厌事无巨细,请尽情阅读吧. 函数指针虽然在语法上让人有些迷惑,但不失为一种有趣而强大的工具.本文将从C ...
- 动态修改 C 语言函数的实现
Objective-C 作为基于 Runtime 的语言,它有非常强大的动态特性,可以在运行期间自省.进行方法调剂.为类增加属性.修改消息转发链路,在代码运行期间通过 Runtime 几乎可以修改 O ...
- keil or c51 汇编调用c语言函数 容易忽视的问题
最近,在用keil 写一个小程序时,想实践一下从汇编调用 C语言函数,我们都知道C语言调用汇编函数讨论得较多,但反过来,从汇编中调用C语言的函数未见深入分析:在开始的时候,还是忽视了一个问题,就是对现 ...
- IOS学习笔记07---C语言函数-printf函数
IOS学习笔记07---C语言函数-printf函数 0 7.C语言5-printf函数 ------------------------- ----------------------------- ...
- IOS学习笔记06---C语言函数
IOS学习笔记06---C语言函数 -------------------------------------------- qq交流群:创梦技术交流群:251572072 ...
随机推荐
- 326 Power of Three 3的幂
给出一个整数,写一个函数来确定这个数是不是3的一个幂.后续挑战:你能不使用循环或者递归完成本题吗? 详见:https://leetcode.com/problems/power-of-three/de ...
- 安装cloudermanager时如何正确Configuring TLS Security for Cloudera Manager
不多说,直接上干货! 参考官网 https://www.cloudera.com/documentation/enterprise/5-2-x/topics/cm_sg_config_tls_secu ...
- HashMap的尾部遍历问题--Tail Traversing
在看网上HashMap的resize()设计时,提到尾部遍历. JDK1.7的HashMap在实现resize()时,新table[]的列表采用LIFO方式,即队头插入.这样做的目的是:避免尾部遍 ...
- window.showModalDialog的问题
通过window.showModalDialog的方式弹出B页面,总报“拒绝访问”的错误,将站点添加到受信任站点可以解决这个问题
- jQuery与js的区别,并有基本语法详解,
通过过一下对比,我们能很清楚的发现jquery与js的区别,运用jquery能大量减少代码量,不过js里面关于时间的setinterval和settimeout只能用js <script src ...
- SQL Server 中4个系统数据库,Master、Model、Msdb、Tempdb。
(1)Master数据库是SQL Server系统最重要的数据库,它记录了SQL Server系统的所有系统信息.这些系统信息包括所有的登录信息.系统设置信息.SQL Server的初始化信息和其他系 ...
- JS——样式获取的兼容写法
样式获取 普通获取属性方式div.style.width或者div.style["width"]无法获取内嵌和外链式,只能获取行内式 window.getComputedStyle ...
- 查看APK包名签名等信息
有些游戏第三方比如分享需要配置游戏包名和签名,不同渠道包名签名又不同,所以时常需要查看不同apk包等签名信息,之前是使用等微博开放平台的手机客户端查看apk签名,前提是知道包名,网上找了下查看签名和包 ...
- TCP报文到达确认(ACK)机制
TCP数据包中的序列号(Sequence Number)不是以报文段来进行编号的,而是将连接生存周期内传输的所有数据当作一个字节流,序列号就是整个字节流中每个字节的编号.一个TCP数据包中包含多个字节 ...
- css流光效果
css流光效果1: <!DOCTYPE html> <html> <head> <title>ww</title> </head> ...