资源描述:
《C语言函数大全(i开头)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、C语言函数大全(i开头)函数名:imagesize功能:返回保存位图像所需的字节数用法:unsignedfarimagesize(intleft,inttop,intright,intbottom);程序例:#include#include#include#include#defineARROW_SIZE10voiddraw_arrow(intx,inty);intmain(void){/*requestautodetection*/intgdriver=DETECT,gmode,errorcode;void*arrow;in
2、tx,y,maxx;unsignedintsize;/*initializegraphicsandlocalvariables*/initgraph(&gdriver,&gmode,"");/*readresultofinitialization*/errorcode=graphresult();if(errorcode!=grOk)/*anerroroccurred*/{printf("Graphicserror:%s",grapherrormsg(errorcode));printf("Pressanykeytohal
3、t:");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
4、);/*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)x=0;/*plotnewimage*/putimage(x,y-ARROW_SIZE,arrow,XOR_PUT);}/*
5、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功能:初始化图形系统用法:voidfarinit
6、graph(intfar*graphdriver,intfar*graphmode,charfar*pathtodriver);程序例:#include#include#include#includeintmain(void){/*requestautodetection*/intgdriver=DETECT,gmode,errorcode;/*initializegraphicsmode*/initgraph(&gdriver,&gmode,"");/*readresultofinitialization*/errorcod
7、e=graphresult();if(errorcode!=grOk)/*anerroroccurred*/{printf("Graphicserror:%s",grapherrormsg(errorcode));printf("Pressanykeytohalt:");getch();exit(1);/*returnwitherrorcode*/}/*drawaline*/line(0,0,getmaxx(),getmaxy());/*cleanup*/getch();closegraph();return0;}函数名:
8、inport功能:从硬件端口中输入用法:intinp(intprotid);程序例:#include#includeintmain(void){intresult;intport=0;/*serialport0*/result=inport(port);printf("Wor