C语言函数大全I文档格式.docx

上传人:b****3 文档编号:16445459 上传时间:2022-11-23 格式:DOCX 页数:11 大小:17.12KB
下载 相关 举报
C语言函数大全I文档格式.docx_第1页
第1页 / 共11页
C语言函数大全I文档格式.docx_第2页
第2页 / 共11页
C语言函数大全I文档格式.docx_第3页
第3页 / 共11页
C语言函数大全I文档格式.docx_第4页
第4页 / 共11页
C语言函数大全I文档格式.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

C语言函数大全I文档格式.docx

《C语言函数大全I文档格式.docx》由会员分享,可在线阅读,更多相关《C语言函数大全I文档格式.docx(11页珍藏版)》请在冰豆网上搜索。

C语言函数大全I文档格式.docx

/*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);

dos.h>

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;

intmidx,midy;

midx=getmaxx()/2;

midy=getmaxy()/2;

/*installauserdefinedfontfile*/

userfont=installuserfont("

USER.CHR"

/*selecttheuserfont*/

settextstyle(userfont,HORIZ_DIR,4);

/*outputsometext*/

outtextxy(midx,midy,"

Testing!

int86

通用8086软中断接口

intint86(intintr_num,unionREGS*inregs,unionREGS*outregs);

#defineVIDEO0x10

voidmovetoxy(intx,inty)

unionREGSregs;

regs.h.ah=2;

/*setcursorpostion*/

regs.h.dh=y;

regs.h.dl=x;

regs.h.bh=0;

/*videopage0*/

int86(VIDEO,&

regs,&

regs);

movetoxy(35,10);

Hello\n"

int86x

intint86x(intintr_num,unionREGS*insegs,unionREGS*outregs,structSREGS*segregs);

process.h>

charfilename[80];

unionREGSinregs,outregs;

structSREGSsegregs;

Enterfilename:

"

gets(filename);

inregs.h.ah=0x43;

inregs.h.al=0x21;

inregs.x.dx=FP_OFF(filename);

segregs.ds=FP_SEG(filename);

int86x(0x21,&

inregs,&

outregs,&

segregs);

Fileattribute:

%X\n"

outregs.x.cx);

intdos

通用DOS接口

intintdos(unionREGS*inregs,unionREGS*outregs);

/*deletesfilename;

returns0onsuccess,nonzeroonfailure*/

intdelete_file(charnear*filename)

intret;

regs.h.ah=0x41;

/*deletefile*/

regs.x.dx=(unsigned)filename;

ret=intdos(&

/*ifcarryflagisset,therewasanerror*/

return(regs.x.cflag?

ret:

0);

interr;

err=delete_file("

NOTEXIST.$$$"

if(!

err)

AbletodeleteNOTEXIST.$$$\n"

NotAbletodeleteNOTEXIST.$$$\n"

intdosx

通用DOS中断接口

intintdosx(unionREGS*inregs,unionREGS*outregs,structSREGS*segregs);

intdelete_file(charfar*filename)

structSREGSsregs;

regs.x.dx=FP_OFF(filename);

sregs.ds=FP_SEG(filename);

ret=intdosx(&

sregs);

intr

改变软中断接口

voidintr(intintr_num,structREGPACK*preg);

string.h>

dir.h>

#defineCF1 

/*Carryflag*/

chardirectory[80];

structREGPACKreg;

Enterdirectorytochangeto:

gets(directory);

reg.r_ax=0x3B<

<

8;

/*shift3Bhinto 

AH*/

reg.r_dx=FP_OFF(directory);

reg.r_ds=FP_SEG(directory);

intr(0x21,&

reg);

if(reg.r_flags&

CF)

Directorychangefailed\n"

getcwd(directory,80);

Thecurrentdirectoryis:

directory);

ioctl

控制I/O设备

intioctl(inthandle,intcmd[,int*argdx,intargcx]);

io.h>

intstat;

/*usefunc8todetermineifthedefaultdriveisremovable*/

stat=ioctl(0,8,0,0);

stat)

Drive%cisremovable.\n"

getdisk()+'

A'

Drive%cisnotremovable.\n"

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1