C语言函数大全s开头1Word格式文档下载.docx
《C语言函数大全s开头1Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《C语言函数大全s开头1Word格式文档下载.docx(40页珍藏版)》请在冰点文库上搜索。
intscanf(char*format[,argument,...]);
charlabel[20];
charname[20];
intentries=0;
intloop,age;
doublesalary;
structEntry_struct
intage;
floatsalary;
}entry[20];
/*Inputalabelasastringofcharactersrestrictingto20characters*/
\n\nPleaseenteralabelforthechart:
"
scanf("
%20s"
label);
fflush(stdin);
/*flushtheinputstreamincaseofbadinput*/
/*Inputnumberofentriesasaninteger*/
Howmanyentrieswilltherebe?
(lessthan20)"
%d"
&
entries);
/*inputanamerestrictinginputtoonlylettersupperorlowercase*/
for(loop=0;
loop
Entry%d\n"
loop);
Name:
%[A-Za-z]"
entry[loop].name);
/*inputanageasaninteger*/
Age:
entry[loop].age);
/*inputasalaryasafloat*/
Salary:
%f"
entry[loop].salary);
/*Inputaname,ageandsalaryasastring,integer,anddouble*/
\nPleaseenteryourname,ageandsalary\n"
%20s%d%lf"
name,&
age,&
salary);
/*Printoutthedatathatwasinput*/
\n\nTable%s\n"
label);
Compiledby%sage%d$%15.2lf\n"
name,age,salary);
-----------------------------------------------------\n"
%4d|%-20s|%5d|%15.2lf\n"
loop+1,
entry[loop].name,
entry[loop].age,
searchpath
搜索DOS路径
char*searchpath(char*filename);
char*p;
/*LooksforTLINKandreturnsapointer
tothepath*/
p=searchpath("
TLINK.EXE"
SearchforTLINK.EXE:
%s\n"
p);
/*Looksfornon-existentfile*/
NOTEXIST.FIL"
SearchforNOTEXIST.FIL:
sector
画并填充椭圆扇区
voidfarsector(intx,inty,intstangle,intendangle);
/*requestautodetection*/
intgdriver=DETECT,gmode,errorcode;
intmidx,midy,i;
intstangle=45,endangle=135;
intxrad=100,yrad=50;
/*initializegraphicsandlocalvariables*/
initgraph(&
gdriver,&
gmode,"
"
/*readresultofinitialization*/
errorcode=graphresult();
if(errorcode!
=grOk)/*anerroroccurred*/
Graphicserror:
grapherrormsg(errorcode));
Pressanykeytohalt:
getch();
exit
(1);
/*terminatewithanerrorcode*/
midx=getmaxx()/2;
midy=getmaxy()/2;
/*loopthroughthefillpatterns*/
for(i=EMPTY_FILL;
i
/*setthefillstyle*/
setfillstyle(i,getmaxcolor());
/*drawthesectorslice*/
sector(midx,midy,stangle,endangle,xrad,yrad);
/*cleanup*/
closegraph();
segread
读段寄存器值
voidsegread(structSREGS*segtbl);
structSREGSsegs;
segread(&
segs);
Currentsegmentregistersettings\n\n"
CS:
%XDS:
%X\n"
segs.cs,segs.ds);
ES:
%XSS:
segs.es,segs.ss);
setactivepage
设置图形输出活动页
voidfarsetactivepage(intpagenum);
/*selectadriverandmodethatsupports*/
/*multiplepages.*/
intgdriver=EGA,gmode=EGAHI,errorcode;
intx,y,ht;
x=getmaxx()/2;
y=getmaxy()/2;
ht=textheight("
W"
/*selecttheoffscreenpagefordrawing*/
setactivepage
(1);
/*drawalineonpage#1*/
line(0,0,getmaxx(),getmaxy());
/*outputamessageonpage#1*/
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(x,y,"
Thisispage#1:
outtextxy(x,y+ht,"
/*selectdrawingtopage#0*/
setactivepage(0);
/*outputamessageonpage#0*/
Thisispage#0."
Pressanykeytoviewpage#1:
/*selectpage#1asthevisiblepage*/
setvisualpage
(1);
setallpallette
按指定方式改变所有的调色板颜色
voidfarsetallpallette(structpalette,far*pallette);
structpalettetypepal;
intcolor,maxcolor,ht;
inty=10;
charmsg[80];
maxcolor=getmaxcolor();
ht=2*textheight("
/*grabacopyofthepalette*/
getpalette(&
pal);
/*displaythedefaultpalettecolors*/
for(color=1;
color<
=maxcolor;
color++)
setcolor(color);
sprintf(msg,"
Color:
%d"
color);
outtextxy(1,y,msg);
y+=ht;
/*waitforakey*/
/*blackoutthecolorsonebyone*/
setpalette(color,BLACK);
/*restorethepalettecolors*/
setallpalette(&
setaspectratio
设置图形纵横比
voidfarsetaspectratio(intxasp,intyasp);
intxasp,yasp,midx,midy;
setcolor(getmaxcolor());
/*getcurrentaspectratiosettings*/
getaspectratio(&
xasp,&
yasp);
/*drawnormalcircle*/
circle(midx,midy,100);
/*claerthescreen*/
cleardevice();
/*adjusttheaspectforawidecircle*/
setaspectratio(xasp/2,yasp);
/*adjusttheaspectforanarrowcircle*/
setaspectratio(xasp,yasp/2);
setbkcolor
用调色板设置当前背景颜色
voidfarsetbkcolor(intcolor);
/*multiplebackgroundcolors.*/
intbkcol,maxcolor,x,y;
/*maximumcolorindexsupported*/
/*forcenteringtextmessages*/
/*loopthroughtheavailablecolors*/
for(bkcol=0;
bkcol<
bkcol++)
/*clearthescreen*/
/*selectanewbackgroundcolor*/
setbkcolor(bkcol);
/*outputamesssage*/
if(bkcol==WHITE)
setcolor(EGA_BLUE);
Backgroundcolor:
bkcol);
outtextxy(x,y,msg);
setblock
修改先前已分配的DOS存储段大小
intsetblock(intseg,intnewsize);
unsignedintsize,segp;
intstat;
size=64;
/*(64x16)=1024bytes*/
stat=allocmem(size,&
segp);
if(stat==-1)
Allocatedmemoryatsegment:
segp);
else
Failed:
maximumnumberofparagraphsavailableis%d\n"
stat);
stat=setblock(segp,size*2);
Expandedmemoryblockatsegment:
freemem(segp);
setbuf
把缓冲区与流相联
voidsetbuf(FILE*steam,char*buf);
/*BUFSIZisdefinedinstdio.h*/
charoutbuf[BUFSIZ];
/*attachabuffertothestandardoutputstream*/
setbuf(stdout,outbuf);
/*putsomecharactersin