C语言库函数D类字母Word文档下载推荐.docx
《C语言库函数D类字母Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《C语言库函数D类字母Word文档下载推荐.docx(14页珍藏版)》请在冰豆网上搜索。
cursorandmovesalllines\
belowitonelineup.\r\n"
DELLINEoperateswithinthe\
currentlyactivetext\r\n"
window.Pressanykeyto\
continue..."
gotoxy(1,2);
/*Movethecursortothe
secondlineandfirstcolumn*/
getch();
delline();
detectgraph
通过检测硬件确定图形驱动程序和模式
voidfardetectgraph(intfar*graphdriver,intfar*graphmode);
graphics.h>
stdlib.h>
stdio.h>
/*namesofthevariouscardssupported*/
char*dname[]={"
requestsdetection"
"
aCGA"
anMCGA"
anEGA"
a64KEGA"
amonochromeEGA"
anIBM8514"
aHerculesmonochrome"
anAT&
T6300PC"
aVGA"
anIBM3270PC"
};
/*returnsdetectedhardwareinfo.*/
intgdriver,gmode,errorcode;
/*detectgraphicshardwareavailable*/
detectgraph(&
gdriver,&
gmode);
/*readresultofdetectgraphcall*/
errorcode=graphresult();
if(errorcode!
=grOk)/*anerror
occurred*/
printf("
Graphicserror:
%s\n"
\
grapherrormsg(errorcode));
Pressanykeytohalt:
exit
(1);
/*terminatewithanerror
code*/
/*displaytheinformationdetected*/
Youhave%svideodisplay\
card.\n"
dname[gdriver]);
difftime
计算两个时刻之间的时间差
doubledifftime(time_ttime2,time_ttime1);
time.h>
time_tfirst,second;
first=time(NULL);
/*Getssystem
time*/
delay(2000);
/*Waits2secs*/
second=time(NULL);
/*Getssystemtime
again*/
Thedifferenceis:
%f\
seconds\n"
difftime(second,first));
disable
屏蔽中断
voiddisable(void);
/***NOTE:
Thisisaninterruptservice
routine.Youcannotcompilethisprogram
withTestStackOverflowturnedonand
getanexecutablefilethatoperates
correctly.*/
#defineINTR0X1C/*Theclocktick
interrupt*/
voidinterrupt(*oldhandler)(void);
intcount=0;
voidinterrupthandler(void)
/*disableinterruptsduringthehandlingof
theinterrupt*/
disable();
/*increasetheglobalcounter*/
count++;
/*reenableinterruptsattheendofthe
handler*/
enable();
/*calltheoldroutine*/
oldhandler();
/*savetheoldinterruptvector*/
oldhandler=getvect(INTR);
/*installthenewinterrupthandler*/
setvect(INTR,handler);
/*loopuntilthecounterexceeds20*/
while(count<
20)
countis%d\n"
count);
/*resettheoldinterrupthandler*/
setvect(INTR,oldhandler);
div
将两个整数相除,返回商和余数
div_t(intnumber,intdenom);
div_tx;
x=div(10,3);
10div3=%dremainder%d\n"
x.quot,x.rem);
dosexterr
获取扩展DOS错误信息
intdosexterr(structDOSERR*dblkp);
FILE*fp;
structDOSERRORinfo;
fp=fopen("
perror.dat"
"
r"
if(!
fp)perror("
Unabletoopenfilefor
reading"
dosexterr(&
info);
ExtendedDOSerror\
information:
\n"
Extendederror:
\
%d\n"
info.exterror);
Class:
%x\n"
info.class);
Action:
info.action);
ErrorLocus:
info.locus);
dostounix
转换日期和时间为UNIX时间格式
longdostounix(structdate*dateptr,structtime*timeptr);
stddef.h>
time_tt;
structtimed_time;
structdated_date;
structtm*local;
getdate(&
d_date);
gettime(&
d_time);
t=dostounix(&
d_date,&
local=localtime(&
t);
TimeandDate:
asctime(local));
drawpoly
画多边形
voidfardrawpoly(intnumpoints,intfar*polypoints);
/*requestautodetection*/
intgdriver=DETECT,gmode,errorcode;
intmaxx,maxy;
/*ourpolygonarray*/
intpoly[10];
/*initializegraphicsandlocal
variables*/
initgraph(&
gmode,"
/*readresultofinitialization*/
=grOk)
/*anerroroccurred*/
/*terminatewithanerrorcode*/
maxx=getmaxx();
maxy=getmaxy();
poly[0]=20;
/*1stvertext*/
poly[1]=maxy/2;
poly[2]=maxx-20;
/*2nd*/
poly[3]=20;
poly[4]=maxx-50;
/*3rd*/
poly[5]=maxy-20;
poly[6]=maxx/2;
/*4th*/
poly[7]=maxy/2;
/*
drawpolydoesn'
tautomaticallyclose
thepolygon,sowecloseit.
*/
poly[8]=poly[0];
poly[9]=poly[1];
/*drawthepolygon*/
drawpoly(5,poly);
/*cleanup*/
closegraph();
dup
复制一个文件句柄
intdup(inthandle);
string.h>
io.h>
voidflush(FILE*stream);
charmsg[]="
Thisisatest"
;
/*createafile*/
DUMMY.FIL"
"
w"
/*writesomedatatothefile*/
fwrite(msg,strlen(msg),1,fp);
Pressanykeytoflush\
DUMMY.FIL:
/*flushthedatatoDUMMY.FILwithout
closingit*/
flush(fp);
\nFilewasflushed,Pressany\
keytoquit:
voidflush(FILE*stream)
intduphandle;
/*flushTC'
sinternalbuffer*/
fflush(stream);
/*makeaduplicatefilehandle*/
duphandle=dup(fileno(stream));
/*closetheduplicatehandletoflushthe
DOSbuffer*/
close(duphandle);
dup2
复制文件句柄
intdup2(intoldhandle,intnewhandle);
sys\stat.h>
fcntl.h>
#defineSTDOUT1
intnul,oldstdout;
nul=open("
O_CREAT│O_RDWR,
S_IREAD│S_IWRITE);
/*createaduplicatehandleforstandard
output*/
oldstdout=dup(STDOUT);
redirectstandardoutputtoDUMMY.FIL
byduplicatingthefilehandleontothe
filehandleforstandardoutput.
dup2(nul,STDOUT);
/*closethehandleforDUMMY.FIL*/
close(nul);
/*willberedirectedintoDUMMY.FIL*/
write(STDOUT,msg,strlen(msg));
/*restoreoriginalstandardoutput
handle*/
dup2(oldstdout,STDOUT);
/*closeduplicatehandleforSTDOUT*/
close(oldstdout);
}