C语言库函数(D类字母)
2008-04-09 03:59:28来源:互联网 阅读 ()
函数名: delay
功 能: 将程序的执行暂停一段时间(毫秒)
用 法: void delay(unsigned milliseconds);
程序例:
/* Emits a 440-Hz tone for 500 milliseconds */
#include <dos.h>
int main(void)
{
sound(440);
delay(500);
nosound();
return 0;
}
函数名: delline
功 能: 在文本窗口中删去一行
用 法: void delline(void);
程序例:
#include <conio.h>
int main(void)
{
clrscr();
cprintf("The function DELLINE deletes \
the line containing the\r\n");
cprintf("cursor and moves all lines \
below it one line up.\r\n");
cprintf("DELLINE operates within the \
currently active text\r\n");
cprintf("window. Press any key to \
continue . . .");
gotoxy(1,2); /* Move the cursor to the
second line and first column */
getch();
delline();
getch();
return 0;
}
函数名: detectgraph
功 能: 通过检测硬件确定图形驱动程序和模式
用 法: void far detectgraph(int far *graphdriver, int far *graphmode);
程序例:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
/* names of the various cards supported */
char *dname[] = { "requests detection",
"a CGA",
"an MCGA",
"an EGA",
"a 64K EGA",
"a monochrome EGA",
"an IBM 8514",
"a Hercules monochrome",
"an AT&T 6300 PC",
"a VGA",
"an IBM 3270 PC"
};
int main(void)
{
/* returns detected hardware info. */
int gdriver, gmode, errorcode;
/* detect graphics hardware available */
detectgraph(&gdriver, &gmode);
/* read result of detectgraph call */
errorcode = graphresult();
if (errorcode != grOk) /* an error
occurred */
{
printf("Graphics error: %s\n", \
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error
code */
}
/* display the information detected */
clrscr();
printf("You have %s video display \
card.\n", dname[gdriver]);
printf("Press any key to halt:");
getch();
return 0;
}
函数名: difftime
功 能: 计算两个时刻之间的时间差
用 法: double difftime(time_t time2, time_t time1);
程序例:
#include <time.h>
#include <stdio.h>
#include <dos.h>
#include <conio.h>
int main(void)
{
time_t first, second;
clrscr();
first = time(NULL); /* Gets system
time */
delay(2000); /* Waits 2 secs */
second = time(NULL); /* Gets system time
again */
printf("The difference is: %f \
seconds\n",difftime(second,first));
getch();
return 0;
}
函数名: disable
功 能: 屏蔽中断
用 法: void disable(void);
程序例:
/***NOTE: This is an interrupt service
routine. You cannot compile this program
with Test Stack Overflow turned on and
get an executable file that operates
correctly. */
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#define INTR 0X1C /* The clock tick
interrupt */
void interrupt ( *oldhandler)(void);
int count=0;
void interrupt handler(void)
{
/* disable interrupts during the handling of
the interrupt */
disable();
/* increase the global counter */
count ;
/* reenable interrupts at the end of the
handler */
enable();
/* call the old routine */
oldhandler();
}
int main(void)
{
/* save the old interrupt vector */
oldhandler = getvect(INTR);
/* install the new interrupt handler */
setvect(INTR, handler);
/* loop until the counter exceeds 20 */
while (count < 20)
printf("count is %d\n",count);
/* reset the old interrupt handler */
setvect(INTR, oldhandler);
return 0;
}
函数名: div
功 能: 将两个整数相除, 返回商和余数
用 法: div_t (int number, int denom);
程序例:
#include <stdlib.h>
#include <stdio.h>
div_t x;
int main(void)
{
x = div(10,3);
printf("10 div 3 = %d remainder %d\n", x.quot, x.rem);
return 0;
}
函数名: dosexterr
功 能: 获取扩展DOS错误信息
用 法: int dosexterr(struct DOSERR *dblkp);
程序例:
#include <stdio.h>
#include <dos.h>
int main(void)
{
FILE *fp;
struct DOSERROR info;
fp = fopen("perror.dat","r");
if (!fp) perror("Unable to open file for
reading");
dosexterr(&info);
printf("Extended DOS error \
information:\n");
printf(" Extended error: \
%d\n",info.exterror);
printf(" Class: \
%x\n",info.class);
printf(" Action: \
%x\n",info.action);
printf(" Error Locus: \
%x\n",info.locus);
return 0;
}
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:C语言库函数(C类字母)
下一篇:C语言库函数(A类字母)
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash