⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d.htm

📁 C语言函数库,包含所有的C语言函数
💻 HTM
字号:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body bgcolor="#00FFFF" text="#000080">

<PRE><font size="5"><a href="a.htm">A</a> <a href="b.htm">B</a> <a href="c.htm">C</a> <a href="d.htm">D</a> <a href="e.htm">E</a> <a href="f.htm">F</a> <a href="g.htm">G</a> <a href="h.htm">H</a> <a href="i.htm">I</a> <a href="k.htm">K</a> <a href="l.htm">L</a> <a href="m.htm">M</a> <a href="n.htm">N</a> <a href="o.htm">O</a> <a href="p.htm">P</a> <a href="q.htm">Q</a> <a href="r.htm">R</a> <a href="s.htm">S</a> <a href="t.htm">T</a> <a href="u.htm">U</a> <a href="v.htm">V</a> <a href="w.htm">W</a> </font></PRE>

<PRE> </PRE>

<PRE>函数大全(d开头)

函数名: <font size="5" color="#FF0000">delay</font> 
功 能: 将程序的执行暂停一段时间(毫秒) 
用 法: void delay(unsigned milliseconds); 
程序例: 
/* Emits a 440-Hz tone for 500 milliseconds */ 
#include </PRE>
<PRE>int main(void) 
{ 
sound(440); 
delay(500); 
nosound(); </PRE>
<PRE>return 0; 
} 

</PRE>
<PRE>函数名: <font size="5" color="#FF0000">delline </font>
功 能: 在文本窗口中删去一行 
用 法: void delline(void); 
程序例: </PRE>
<PRE>#include </PRE>
<PRE>int main(void) 
{ 
clrscr(); 
cprintf(&quot;The function DELLINE deletes \ 
the line containing the\r\n&quot;); 
cprintf(&quot;cursor and moves all lines \ 
below it one line up.\r\n&quot;); 
cprintf(&quot;DELLINE operates within the \ 
currently active text\r\n&quot;); 
cprintf(&quot;window. Press any key to \ 
continue . . .&quot;); 
gotoxy(1,2); /* Move the cursor to the 
second line and first column */ 
getch(); </PRE>
<PRE>delline(); 
getch(); </PRE>
<PRE>return 0; 
} 
</PRE>
<PRE>函数名: <font size="5" color="#FF0000">detectgraph </font>
功 能: 通过检测硬件确定图形驱动程序和模式 
用 法: void far detectgraph(int far *graphdriver, int far *graphmode); 
程序例: </PRE>
<PRE>#include 
#include 
#include 
#include </PRE>
<PRE>/* names of the various cards supported */ 
char *dname[] = { &quot;requests detection&quot;, 
&quot;a CGA&quot;, 
&quot;an MCGA&quot;, 
&quot;an EGA&quot;, 
&quot;a 64K EGA&quot;, 
&quot;a monochrome EGA&quot;, 
&quot;an IBM 8514&quot;, 
&quot;a Hercules monochrome&quot;, 
&quot;an AT&amp;T 6300 PC&quot;, 
&quot;a VGA&quot;, 
&quot;an IBM 3270 PC&quot; 
}; </PRE>
<PRE>int main(void) 
{ 
/* returns detected hardware info. */ 
int gdriver, gmode, errorcode; </PRE>
<PRE>/* detect graphics hardware available */ 
detectgraph(&amp;gdriver, &amp;gmode); </PRE>
<PRE>/* read result of detectgraph call */ 
errorcode = graphresult(); 
if (errorcode != grOk) /* an error 
occurred */ 
{ 
printf(&quot;Graphics error: %s\n&quot;, \ 
grapherrormsg(errorcode)); 
printf(&quot;Press any key to halt:&quot;); 
getch(); 
exit(1); /* terminate with an error 
code */ 
} </PRE>
<PRE>/* display the information detected */ 
clrscr(); 
printf(&quot;You have %s video display \ 
card.\n&quot;, dname[gdriver]); 
printf(&quot;Press any key to halt:&quot;); 
getch(); 
return 0; 
} 


</PRE>
<PRE>函数名:<font size="5" color="#FF0000"> difftime </font>
功 能: 计算两个时刻之间的时间差 
用 法: double difftime(time_t time2, time_t time1); 
程序例: </PRE>
<PRE>#include 
#include 
#include 
#include </PRE>
<PRE>int main(void) 
{ 
time_t first, second; </PRE>
<PRE>clrscr(); 
first = time(NULL); /* Gets system 
time */ 
delay(2000); /* Waits 2 secs */ 
second = time(NULL); /* Gets system time 
again */ </PRE>
<PRE>printf(&quot;The difference is: %f \ 
seconds\n&quot;,difftime(second,first)); 
getch(); </PRE>
<PRE>return 0; 
} 

</PRE>
<PRE>函数名:<font size="5" color="#FF0000"> disable </font>
功 能: 屏蔽中断 
用 法: void disable(void); 
程序例: </PRE>
<PRE>/***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. */ </PRE>
<PRE>#include 
#include 
#include </PRE>
<PRE>#define INTR 0X1C /* The clock tick 
interrupt */ </PRE>
<PRE>void interrupt ( *oldhandler)(void); </PRE>
<PRE>int count=0; </PRE>
<PRE>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(); 
} </PRE>
<PRE>int main(void) 
{ 
/* save the old interrupt vector */ 
oldhandler = getvect(INTR); </PRE>
<PRE>/* install the new interrupt handler */ 
setvect(INTR, handler); </PRE>
<PRE>/* loop until the counter exceeds 20 */ 
while (count &lt; 20) 
printf(&quot;count is %d\n&quot;,count); </PRE>
<PRE>/* reset the old interrupt handler */ 
setvect(INTR, oldhandler); </PRE>
<PRE>return 0; 
} </PRE>
<PRE>函数名:<font size="5" color="#FF0000"> div </font>
功 能: 将两个整数相除, 返回商和余数 
用 法: div_t (int number, int denom); 
程序例: </PRE>
<PRE>#include 
#include </PRE>
<PRE>div_t x; </PRE>
<PRE>int main(void) 
{ 
x = div(10,3); 
printf(&quot;10 div 3 = %d remainder %d\n&quot;, x.quot, x.rem); </PRE>
<PRE>return 0; 
} 

</PRE>
<PRE>函数名: <font size="5" color="#FF0000">dosexterr </font>
功 能: 获取扩展DOS错误信息 
用 法: int dosexterr(struct DOSERR *dblkp); 
程序例: </PRE>
<PRE>#include 
#include </PRE>
<PRE>int main(void) 
{ 
FILE *fp; 
struct DOSERROR info; </PRE>
<PRE>fp = fopen(&quot;perror.dat&quot;,&quot;r&quot;); 
if (!fp) perror(&quot;Unable to open file for 
reading&quot;); 
dosexterr(&amp;info); </PRE>
<PRE>printf(&quot;Extended DOS error \ 
information:\n&quot;); 
printf(&quot; Extended error: \ 
%d\n&quot;,info.exterror); 
printf(&quot; Class: \ 
%x\n&quot;,info.class); 
printf(&quot; Action: \ 
%x\n&quot;,info.action); 
printf(&quot; Error Locus: \ 
%x\n&quot;,info.locus); </PRE>
<PRE>return 0; 
} 

</PRE>
<PRE>函数名: <font size="5" color="#FF0000">dostounix </font>
功 能: 转换日期和时间为UNIX时间格式 
用 法: long dostounix(struct date *dateptr, struct time *timeptr); 
程序例: </PRE>
<PRE>#include 
#include 
#include 
#include </PRE>
<PRE>int main(void) 
{ 
time_t t; 
struct time d_time; 
struct date d_date; 
struct tm *local; </PRE>
<PRE>getdate(&amp;d_date); 
gettime(&amp;d_time); </PRE>
<PRE>t = dostounix(&amp;d_date, &amp;d_time); 
local = localtime(&amp;t); 
printf(&quot;Time and Date: %s\n&quot;, \ 
asctime(local)); </PRE>
<PRE>return 0; 
} 

</PRE>
<PRE>函数名: <font size="5" color="#FF0000">drawpoly </font>
功 能: 画多边形 
用 法: void far drawpoly(int numpoints, int far *polypoints); 
程序例: </PRE>
<PRE>#include 
#include 
#include 
#include </PRE>
<PRE>int main(void) 
{ 
/* request auto detection */ 
int gdriver = DETECT, gmode, errorcode; 
int maxx, maxy; </PRE>
<PRE>/* our polygon array */ 
int poly[10]; </PRE>
<PRE>/* initialize graphics and local 
variables */ 
initgraph(&amp;gdriver, &amp;gmode, &quot;&quot;); </PRE>
<PRE>/* read result of initialization */ 
errorcode = graphresult(); 
if (errorcode != grOk) 
/* an error occurred */ 
{ 
printf(&quot;Graphics error: %s\n&quot;, \ 
grapherrormsg(errorcode)); 
printf(&quot;Press any key to halt:&quot;); 
getch(); 
/* terminate with an error code */ 
exit(1); 
} </PRE>
<PRE>maxx = getmaxx(); 
maxy = getmaxy(); </PRE>
<PRE>poly[0] = 20; /* 1st vertext */ 
poly[1] = maxy / 2; </PRE>
<PRE>poly[2] = maxx - 20; /* 2nd */ 
poly[3] = 20; </PRE>
<PRE>poly[4] = maxx - 50; /* 3rd */ 
poly[5] = maxy - 20; </PRE>
<PRE>poly[6] = maxx / 2; /* 4th */ 
poly[7] = maxy / 2; 
/* 
drawpoly doesn't automatically close 
the polygon, so we close it. 
*/ 
poly[8] = poly[0]; 
poly[9] = poly[1]; </PRE>
<PRE>/* draw the polygon */ 
drawpoly(5, poly); </PRE>
<PRE>/* clean up */ 
getch(); 
closegraph(); 
return 0; 
} 

</PRE>
<PRE>函数名: <font size="5" color="#FF0000">dup </font>
功 能: 复制一个文件句柄 
用 法: int dup(int handle); 
程序例: </PRE>
<PRE>#include 
#include 
#include 
#include </PRE>
<PRE>void flush(FILE *stream); </PRE>
<PRE>int main(void) 
{ 
FILE *fp; 
char msg[] = &quot;This is a test&quot;; </PRE>
<PRE>/* create a file */ 
fp = fopen(&quot;DUMMY.FIL&quot;, &quot;w&quot;); </PRE>
<PRE>/* write some data to the file */ 
fwrite(msg, strlen(msg), 1, fp); </PRE>
<PRE>clrscr(); 
printf(&quot;Press any key to flush \ 
DUMMY.FIL:&quot;); 
getch(); </PRE>
<PRE>/* flush the data to DUMMY.FIL without 
closing it */ 
flush(fp); </PRE>
<PRE>printf(&quot;\nFile was flushed, Press any \ 
key to quit:&quot;); 
getch(); 
return 0; 
} </PRE>
<PRE>void flush(FILE *stream) 
{ 
int duphandle; </PRE>
<PRE>/* flush TC's internal buffer */ 
fflush(stream); </PRE>
<PRE>/* make a duplicate file handle */ 
duphandle = dup(fileno(stream)); </PRE>
<PRE>/* close the duplicate handle to flush the 
DOS buffer */ 
close(duphandle); 
} 

</PRE>
<PRE>函数名: <font size="5" color="#FF0000">dup2 </font>
功 能: 复制文件句柄 
用 法: int dup2(int oldhandle, int newhandle); 
程序例: </PRE>
<PRE>#include 
#include 
#include 
#include </PRE>
<PRE>int main(void) 
{ 
#define STDOUT 1 </PRE>
<PRE>int nul, oldstdout; 
char msg[] = &quot;This is a test&quot;; </PRE>
<PRE>/* create a file */ 
nul = open(&quot;DUMMY.FIL&quot;, O_CREAT | O_RDWR, 
S_IREAD | S_IWRITE); </PRE>
<PRE>/* create a duplicate handle for standard 
output */ 
oldstdout = dup(STDOUT); 
/* 
redirect standard output to DUMMY.FIL 
by duplicating the file handle onto the 
file handle for standard output. 
*/ 
dup2(nul, STDOUT); </PRE>
<PRE>/* close the handle for DUMMY.FIL */ 
close(nul); </PRE>
<PRE>/* will be redirected into DUMMY.FIL */ 
write(STDOUT, msg, strlen(msg)); </PRE>
<PRE>/* restore original standard output 
handle */ 
dup2(oldstdout, STDOUT); </PRE>
<PRE>/* close duplicate handle for STDOUT */ 
close(oldstdout); </PRE>
<PRE>return 0; 
} </PRE>
<pre></pre>

<PRE><font size="5"><a href="a.htm">A</a> <a href="b.htm">B</a> <a href="c.htm">C</a> <a href="d.htm">D</a> <a href="e.htm">E</a> <a href="f.htm">F</a> <a href="g.htm">G</a> <a href="h.htm">H</a> <a href="i.htm">I</a> <a href="k.htm">K</a> <a href="l.htm">L</a> <a href="m.htm">M</a> <a href="n.htm">N</a> <a href="o.htm">O</a> <a href="p.htm">P</a> <a href="q.htm">Q</a> <a href="r.htm">R</a> <a href="s.htm">S</a> <a href="t.htm">T</a> <a href="u.htm">U</a> <a href="v.htm">V</a> <a href="w.htm">W</a> </font></PRE>

<pre></pre>
<pre> </pre>
<pre>资料收集:beck Copyright 2004 张求熙, All Rights Reserved</pre>
<pre><a href="mailto:Email:qiuxi1984@126.com">Email:qiuxi1984@126.com</a>     QQ:35540948 </pre>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -