C语言函数大全i开头Word下载.docx
《C语言函数大全i开头Word下载.docx》由会员分享,可在线阅读,更多相关《C语言函数大全i开头Word下载.docx(12页珍藏版)》请在冰豆网上搜索。
intmain(void)
{
/*requestautodetection*/
intgdriver=DETECT,gmode,errorcode;
void*arrow;
intx,y,maxx;
unsignedintsize;
/*initializegraphicsandlocalvariables*/
initgraph(&
gdriver,&
gmode,"
"
);
/*readresultofinitialization*/
errorcode=graphresult();
if(errorcode!
=grOk)/*anerroroccurred*/
printf("
Graphicserror:
%s\n"
grapherrormsg(errorcode));
Pressanykeytohalt:
getch();
exit
(1);
/*terminatewithanerrorcode*/
}
maxx=getmaxx();
x=0;
y=getmaxy()/2;
/*drawtheimagetobegrabbed*/
draw_arrow(x,y);
/*calculatethesizeoftheimage*/
size=imagesize(x,y-ARROW_SIZE,x+(4*ARROW_SIZE),y+ARROW_SIZE);
/*allocatememorytoholdtheimage*/
arrow=malloc(size);
/*grabtheimage*/
getimage(x,y-ARROW_SIZE,x+(4*ARROW_SIZE),y+ARROW_SIZE,arrow);
/*repeatuntilakeyispressed*/
while(!
kbhit())
/*eraseoldimage*/
putimage(x,y-ARROW_SIZE,arrow,XOR_PUT);
x+=ARROW_SIZE;
if(x>
=maxx)
/*plotnewimage*/
/*cleanup*/
free(arrow);
closegraph();
return0;
voiddraw_arrow(intx,inty)
/*drawanarrowonthescreen*/
moveto(x,y);
linerel(4*ARROW_SIZE,0);
linerel(-2*ARROW_SIZE,-1*ARROW_SIZE);
linerel(0,2*ARROW_SIZE);
linerel(2*ARROW_SIZE,-1*ARROW_SIZE);
initgraph
初始化图形系统
voidfarinitgraph(intfar*graphdriver,intfar*graphmode,
charfar*pathtodriver);
/*requestautodetection*/
/*initializegraphicsmode*/
/*returnwitherrorcode*/
/*drawaline*/
line(0,0,getmaxx(),getmaxy());
inport
从硬件端口中输入
intinp(intprotid);
intresult;
intport=0;
/*serialport0*/
result=inport(port);
Wordreadfromport%d=0x%X\n"
port,result);
insline
在文本窗口中插入一个空行
voidinsline(void);
clrscr();
cprintf("
INSLINEinsertsanemptylineinthetextwindow\r\n"
atthecursorpositionusingthecurrenttext\r\n"
backgroundcolor.Alllinesbelowtheemptyone\r\n"
movedownonelineandthebottomlinescrolls\r\n"
offthebottomofthewindow.\r\n"
\r\nPressanykeytocontinue:
gotoxy(1,3);
insline();
installuserdriver
安装设备驱动程序到BGI设备驱动程序表中
intfarinstalluserdriver(charfar*name,int(*detect)(void));
/*functionprototypes*/
inthugedetectEGA(void);
voidcheckerrors(void);
intgdriver,gmode;
/*installauserwrittendevicedriver*/
gdriver=installuserdriver("
EGA"
detectEGA);
/*mustforceuseofdetectionroutine*/
gdriver=DETECT;
/*checkforanyinstallationerrors*/
checkerrors();
/*checkforanyinitializationerrors*/
/*detectsEGAorVGAcards*/
inthugedetectEGA(void)
intdriver,mode,sugmode=0;
detectgraph(&
driver,&
mode);
if((driver==EGA)||(driver==VGA))
/*returnsuggestedvideomodenumber*/
returnsugmode;
else
/*returnanerrorcode*/
returngrError;
/*checkforandreportanygraphicserrors*/
voidcheckerrors(void)
interrorcode;
/*readresultoflastgraphicsoperation*/
=grOk)
installuserfont
安装未嵌入BGI系统的字体文件(CHR)
intfarinstalluserfont(charfar*name);
/*functionprototype*/
intgdriver=DETECT,gmode;
intuserfont;