C语言函数大全p开头docx.docx

上传人:b****7 文档编号:26519502 上传时间:2023-06-20 格式:DOCX 页数:19 大小:18.76KB
下载 相关 举报
C语言函数大全p开头docx.docx_第1页
第1页 / 共19页
C语言函数大全p开头docx.docx_第2页
第2页 / 共19页
C语言函数大全p开头docx.docx_第3页
第3页 / 共19页
C语言函数大全p开头docx.docx_第4页
第4页 / 共19页
C语言函数大全p开头docx.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

C语言函数大全p开头docx.docx

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

C语言函数大全p开头docx.docx

C语言函数大全p开头docx

函数大全(p开头)

61

函数名:

parsfnm

功能:

分析文件名

用法:

char*parsfnm(char*cmdline,structfcb*fcbptr,intoption);程序例:

#include

#include

#include

#include

intmain(void)

{

charline[80];

structfcbblk;

/*getfilename*/

printf(MEnterdriveandfilename(nopath-ie.a:

file.dat)\nM);gets(line);

/*putfilenameinfcb*/

if(parsfnm(line,&blk,1)==NULL)

printf(MErrorinparsfmcall\nH);

else

printf("Drive#%dName:

%1ls\n",blk.fcb_drive,blk.fcb_name);

return0;

函数名:

peek

功能:

检查存储单元

用法:

intpeek(intsegment,unsignedoffset);程序例:

#include

#include

#include

intmain(void)

intvalue=0;

prinif(=ThecurrentsUHusofyourkeyboardis,n=);valueHPeek(oxoo4p0x0017)八if(value1)

PS-二f(--Rightshiftonm=)八

else

printaRightshift05n=)八

if(value2)

primf(=Lefrshiftonvr.r

else

prin-fTLenshiftO51T);

if(value&.4)printf(=con=rolkeyon\n=)_

else

prin.s=co=ro】keyoff\n=)八

if(valueRp8)

printf(=Alrkeyon\n=)一

else

prins->-tkey03=)

 

if(vace8l16)prin〔f(=scro=ock02n=r

elseprimf(=scro=ockoff\n=);

if(vace8c32)primf(=Numlockon\n=);

elseprinif(=Numockoff\n=);

if(vace8l64)

primacapslockonw);

else

primf(二capsock03=)

rerun-p

因磬Ik【peekb

 

功能:

检查存储单元

用法:

charpeekb(intsegment,unsignedoffset);程序例:

#include

#include

#include

intmain(void)

{

intvalue=0;

printf("Thecurrentstatusofyourkeyboardis:

\n");value=peekb(0x0040,0x0017);

if(value&1)

printf("Rightshifton\n");

else

printf(MRightshiftoff\nM);

if(value&2)

printf("Leftshifton\n");

else

printf("Leftshiftoff\nH);

if(value&4)

printf(''Controlkeyon\nH);

else

printf("Controlkeyoff\n");

if(value&8)

printf("Altkeyon\n");

else

printf("AltkeyoflAn");

if(value&16)

printf("Scrolllockon\nu);

else

printfC'Scrolllockoff\n,f);

if(value&32)

printfC'Numlockon\nu);

else

printf("Numlockoff\nu);

if(value&64)printfC'Capslockon\n");

else

printf(HCapslockoff\n");

return0;

函数名:

perror

功能:

系统错误信息

用法:

voidperror(char^string);

程序例:

#include

intmain(void)

{

FILE*fp;

fp=fopen("peiTor.dat'\"r");

perror(HUnabletoopenfileforreading0);return0;

函数名:

pieslice

功能:

绘制并填充一个扇形

用法:

voidfarpieslice(intx,intstanle,intendangle,intradius);程序例:

#include

#include

#include

#include

intmain(void)

{

/*requestautodetection*/

intgdriver=DETECT,gmode,errorcode;

intmidx,midy;

intstangle=45,endangle=135,radius=100;

/*initializegraphicsandlocalvariables*/initgraph(&gdriver,&gmode,HH);

/*readresultofinitialization*/

errorcode=graphresult();

if(errorcode!

=grOk)/*anerroroccurred*/

{

printf(HGraphicserror:

%s\nH,grapheiTormsg(errorcode));printf(nPressanykeytohalt:

H);

getch();

exit(l);/*terminatewithanerrorcode*/

midx=getmaxx()/2;midy=getmaxy()/2;

/*setfillstyleanddrawapieslice*/setfillstyle(EMPTY_FILL,getmaxcolor());pieslice(midx,midy,stangle,endangle,radius);

/*cleanup*/getch();closegraph();return0;

函数名:

poke

功能:

存值到一个给定存储单元

用法:

voidpoke(intsegment,intoffset,intvalue);

程序例:

#include

#include

intmain(void)

{

clrscr();

cprintf(nMakesurethescrolllockkeyisoffandpressanykey\r\nH);getch();

poke(0x0000,0x0417,16);

cprintf(nThescrolllockisnowon\r\nH);return0;

函数名:

pokeb

功能:

存值到一个给定存储单元

用法:

voidpokeb(intsegment,intoffset,charvalue);

程序例:

#include

#include

intmain(void)

{

clrscr();

cprintf(HMakesurethescrolllockkeyisoffandpressanykey\r\nH);getch();

pokeb(0x0000,0x0417,16);

cprintf(nThescrolllockisnowon\r\nM);

return0;

函数名:

poly

功能:

根据参数产生一个多项式

用法:

doublepoly(doublex,intn,doublec[J);

程序例:

#include

#include

/*polynomial:

x**3・2x**2+5x・1*/

intmain(void)

{

doublearray[]={-1.0,5.0,-2.0,1.0};

doubleresult;

result=poly(2.0,3,array);

printf("Thepolynomial:

x**3-2.0x**2+5x-1at2.0is%lf\n",result);

return0;

函数名:

pow

功能:

指数函数(x的y次方)

用法:

doublepow(doublex,doubley);

程序例:

#include

#include

intmain(void)

{

doublex=2.0,y=3.0;

printf("%lfraisedto%lfisx,y,pow(x,y));

return0;

}

函数名:

pow10

功能:

指数函数(10的p次方)用法:

doublepowl0(intp);

程序例:

#include

#inelude

intmain(void)

{

doublep=3.0;

printf(MTenraisedto%lfis%lf\nH,p,powlO(p));return0;

函数名:

printf

功能:

产生格式化输出的函数用法:

intprintf(char*format…);程序例:

#include

#include#defineI555

#defineR5.5

intmain(void)

{

inti,j,k,l;

charbuf[71;

char^prefix=buf;

chartp[20];

printf(Mprefix6d608x10.2e

”10.22”);

strcpy(prefix,"%n);

for(i=0;i<2;i++)

{

for(j=0;j<2;j++)

for(k=0;k<2;k++)

for(1=0;1<2;1++)

{

if(i==0)strcat(prefix,H-H);

讦(j==0)strcat(prefix,H+n);

if(k==0)strcat(prefix,*'#");

if(l==0)strcat(prefix,HOM);printf("%5s|u,prefix);strcpy(tp,prefix);

strcat(tp/'6dprintf(tp,I);strcpy(tp;M,);

strcpy(tp,prefix);

strcat(tp;'6o|H);printf(tp,I);

strcpy(tp;n,);strcpy(tp,prefix);

strcat(tp,"8xprintf(tp,I);

strcpy(tp;,H);strcpy(tp,prefix);

strcat(tp,"10.2eprintf(tp,R);

strcpy(tp,prefix);

strcat(tp,”10.2iT);

printf(tp,R);printfC\nH);strcpy(prefix/'%");

}

return0;

函数名:

putc

功能:

输出一字符到指定流中

用法:

intputc(intch,FILE*stream);程序例:

#include

intmain(void)

{

charmsg[]=MHelloworld\nH;

inti=0;

while(msg[i])

putc(msg[i++],stdout);

return0;

函数名:

putch

功能:

输出字符到控制台用法:

intputch(intch);

程序例:

#include

#includeintmain(void)

{

charch=0;

printf(MInputastring:

”);while((ch!

=V))ch=getch();putch(ch);

}

return0;

}

函数名:

putchar

功能:

在stdout±输出字符

用法:

intputchar(intch);

程序例:

#include

/*definesomebox-drawingcharacters*/

#defineLEFT_TOPOxDA

#defineRIGHT_TOPOxBF

#defineHORIZ0xC4

#defineVERT0xB3

#defineLEFT.BOTOxCO

#defineRIGHT.BOT0xD9

intmain(void)

{

chari,j;

/*drawthetopofthebox*/putchar(LEFT_TOP);

for(i=0;i<10;i++)

putchar(HORIZ);

putchar(RIGHT_TOP);putcharC^n');

/*drawthemiddle*/

for(i=0;i<4;i++)

{

putchar(VERT);for(j=0;j<10;j++)

putchar('');

putchar(VERT);

putchar('\n');

/*drawthebottom*/putchar(LEFT_BOT);for(i=0;i<10;i++)putchar(HORIZ);

putchar(RIGHT_BOT);putchar('\n‘);

return0;

函数名:

putenv

功能:

把字符串加到当前环境中

用法:

intputenv(char*envvar);

程序例:

#include

#include

#include

#include

#include

intmain(void)

{

char*path,*ptr;

inti=0;

/*getthecurrentpathenvi「onment*/

ptr=getenv("PATHM);

/*setupnewpath♦/

path=malloc(strlen(ptr)+15);

strcpy(path,MPATH=M);

strcat(path,ptr);

strcat(path/,;c:

\\tempu);

/*replacethecurrentpathanddisplaycurrentenvironment*/putenv(path);

while(environ[i])

printf("%s\n",environfi++]);

return0;

函数名:

putimage

功能:

在屏幕上输出一个位图

用了去:

voidfarputimage(intx,inty,voidfar^bitmap,intop);程序例:

#inelude

#include

#include

#include

#defineARROW_S1ZE10voiddraw_arrow(intx,inty);

intmain(void)

{

/*requestautodetection*/

intgdriver=DETECT,gmode,errorcode;

void*arrow;

intx,y,maxx;

unsignedintsize;

/*initializegraphicsandlocalvariables*/

initgraph(&gdrivei\&gmode,HU);

/*readresultofinitialization*/

errorcode=graphresult();

if(errorcode!

=grOk)/*anerroroccurred*/

{

printf(nGraphicserror:

%s\nM,grapheiTormsg(errorcode));printf(HPressanykeytohalt:

”);

getch();

exit(l);/*terminatewithanerrorcode*/

}

maxx=getmaxx();

x=0;

y=getmaxyO/2;

/*drawtheimagetobegrabbed*/

draw_arrow(x,y);

/*calculatethesizeoftheimage*/

size=imagesize(x,y-ARROW_SIZE,x+(4*ARR0W_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)

x=0;

/*plotnewimage*/

putimage(x,y-ARROW_SIZE,arrow,XOR_PUT);

/*cleanup*/free(aiTow);closegraph();return0;

voiddraw_arrow(intx,inty)

{

/*drawanarrowonthescreen*/moveto(x,y);

linerel(4*ARROW_SIZE,0);

linerel(-2*ARROW_SIZE,-1*ARROW_SIZE);linereKO,2*ARROW_SIZE);

linerel(2*ARROW_SIZE,-1*ARROW_SIZE);

函数名:

putpixel

功能:

在指定位置画一像素用法:

voidfarputpixel(intx,inty,intpixelcolor);程序例:

#inelude

#include

#include#include

#include#definePIXEL_COUNT1000

#defineDELAYTIME100/*inmilliseconds*/intmain(void)

{

/*requestautodetection*/

intgdriver=DETECT,gmode,errorcode;

inti,x,y,color,maxx,maxy,maxcolor,seed;

/*initializegraphicsandlocalvariables*/

initgraph(&gdriver,&gmode,HU);

/*readresultofinitialization*/

errorcode=graphresult();

if(errorcode!

=grOk)/*anerroroccurred*/

{

printf(nGraphicserror:

%s\n'\grapheiTormsg(errorcode));printf(HPressanykeytohalt:

11);

getch();

exit(l);/*terminatewithanerrorcode*/

maxx=getmaxx()+1;

maxy=getmaxy()+1;

maxcolor=getmaxcolor()+1;

while(!

kbhit())

{

/*seedtherandomnumbergenerator*/

seed=random(32767);

srand(seed);

for(i=0;i

{

x=random(maxx);

y=random(niaxy);

color=random(maxcolor);putpixel(x,y,color);

}

delay(DELAY_TIME);srand(seed);

for(i=0;i

x=random(maxx);

y=random(maxy);

color=random(maxcolor);

if(color==getpixel(x,y))putpixel(x,y,0);

/*cleanup*/getch();closegraph();return0;

函数名:

puts

功能:

送一字符串

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

当前位置:首页 > 医药卫生 > 基础医学

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

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