?? d.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("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(); </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[] = { "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"
}; </PRE>
<PRE>int main(void)
{
/* returns detected hardware info. */
int gdriver, gmode, errorcode; </PRE>
<PRE>/* detect graphics hardware available */
detectgraph(&gdriver, &gmode); </PRE>
<PRE>/* 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 */
} </PRE>
<PRE>/* display the information detected */
clrscr();
printf("You have %s video display \
card.\n", dname[gdriver]);
printf("Press any key to halt:");
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("The difference is: %f \
seconds\n",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 < 20)
printf("count is %d\n",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("10 div 3 = %d remainder %d\n", 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("perror.dat","r");
if (!fp) perror("Unable to open file for
reading");
dosexterr(&info); </PRE>
<PRE>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); </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(&d_date);
gettime(&d_time); </PRE>
<PRE>t = dostounix(&d_date, &d_time);
local = localtime(&t);
printf("Time and Date: %s\n", \
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(&gdriver, &gmode, ""); </PRE>
<PRE>/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk)
/* an error occurred */
{
printf("Graphics error: %s\n", \
grapherrormsg(errorcode));
printf("Press any key to halt:");
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[] = "This is a test"; </PRE>
<PRE>/* create a file */
fp = fopen("DUMMY.FIL", "w"); </PRE>
<PRE>/* write some data to the file */
fwrite(msg, strlen(msg), 1, fp); </PRE>
<PRE>clrscr();
printf("Press any key to flush \
DUMMY.FIL:");
getch(); </PRE>
<PRE>/* flush the data to DUMMY.FIL without
closing it */
flush(fp); </PRE>
<PRE>printf("\nFile was flushed, Press any \
key to quit:");
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[] = "This is a test"; </PRE>
<PRE>/* create a file */
nul = open("DUMMY.FIL", 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 + -