1、函数大全p开头解读函数大全(p开头)函数名:parsfnm 功能:分析文件名 用法:char*parsfnm(char*cmdline,structfcb*fcbptr,intoption); 程序例: #include #include #include #includeintmain(void) charline80; structfcbblk; /*getfilename*/ printf(Enterdriveandfilename(nopath-ie.a:file.dat)n); gets(line); /*putfilenameinfcb*/ if(parsfnm(line,&blk
2、,1)=NULL) printf(Errorinparsfmcalln); else printf(Drive#%dName:%11sn,blk.fcb_drive,blk.fcb_name); return0; 函数名:peek 功能:检查存储单元 用法:intpeek(intsegment,unsignedoffset); 程序例: #include #include #include intmain(void) intvalue=0; printf(Thecurrentstatusofyourkeyboardis:n); value=peek(0x0040,0x0017); if(val
3、ue&1) printf(Rightshiftonn); else printf(Rightshiftoffn); if(value&2) printf(Leftshiftonn); else printf(Leftshiftoffn); if(value&4) printf(Controlkeyonn); else printf(Controlkeyoffn); if(value&8) printf(Altkeyonn); else printf(Altkeyoffn); if(value&16) printf(Scrolllockonn); else printf(Scrolllockof
4、fn); if(value&32) printf(Numlockonn); else printf(Numlockoffn); if(value&64) printf(Capslockonn); else printf(Capslockoffn); return0; 函数名:peekb 功能:检查存储单元 用法:charpeekb(intsegment,unsignedoffset); 程序例: #include #include #include intmain(void) intvalue=0; printf(Thecurrentstatusofyourkeyboardis:n); val
5、ue=peekb(0x0040,0x0017); if(value&1) printf(Rightshiftonn); else printf(Rightshiftoffn); if(value&2) printf(Leftshiftonn); else printf(Leftshiftoffn); if(value&4) printf(Controlkeyonn); else printf(Controlkeyoffn); if(value&8) printf(Altkeyonn); else printf(Altkeyoffn); if(value&16) printf(Scrollloc
6、konn); else printf(Scrolllockoffn); if(value&32) printf(Numlockonn); else printf(Numlockoffn); if(value&64) printf(Capslockonn); else printf(Capslockoffn); return0; 函数名:perror 功能:系统错误信息 用法:voidperror(char*string); 程序例: #include intmain(void) FILE*fp; fp=fopen(perror.dat,r); if(!fp) perror(Unabletoop
7、enfileforreading); 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; /*initializegraphics
8、andlocalvariables*/ initgraph(&gdriver,&gmode,); /*readresultofinitialization*/ errorcode=graphresult(); if(errorcode!=grOk)/*anerroroccurred*/ printf(Graphicserror:%sn,grapherrormsg(errorcode); printf(Pressanykeytohalt:); getch(); exit(1);/*terminatewithanerrorcode*/ midx=getmaxx()/2; midy=getmaxy(
9、)/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(Makesurethe
10、scrolllockkeyisoffandpressanykeyrn); getch(); poke(0x0000,0x0417,16); cprintf(Thescrolllockisnowonrn); return0; 函数名:pokeb 功能:存值到一个给定存储单元 用法:voidpokeb(intsegment,intoffset,charvalue); 程序例: #include #include intmain(void) clrscr(); cprintf(Makesurethescrolllockkeyisoffandpressanykeyrn); getch(); pokeb
11、(0x0000,0x0417,16); cprintf(Thescrolllockisnowonrn); return0; 函数名:poly 功能:根据参数产生一个多项式 用法:doublepoly(doublex,intn,doublec); 程序例: #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.
12、0is%lfn, result); return0; 函数名:pow 功能:指数函数(x的y次方) 用法:doublepow(doublex,doubley); 程序例: #include #include intmain(void) doublex=2.0,y=3.0; printf(%lfraisedto%lfis%lfn,x,y,pow(x,y); return0; 函数名:pow10 功能:指数函数(10的p次方) 用法:doublepow10(intp); 程序例: #include #include intmain(void) doublep=3.0; printf(Tenrais
13、edto%lfis%lfn,p,pow10(p); return0; 函数名:printf 功能:产生格式化输出的函数 用法:intprintf(char*format.); 程序例: #include #include #defineI555 #defineR5.5 intmain(void) inti,j,k,l; charbuf7; char*prefix=buf; chartp20; printf(prefix6d6o8x10.2e 10.2fn); strcpy(prefix,%); for(i=0;i2;i+) for(j=0;j2;j+) for(k=0;k2;k+) for(l
14、=0;l2;l+) if(i=0)strcat(prefix,-); if(j=0)strcat(prefix,+); if(k=0)strcat(prefix,#); if(l=0)strcat(prefix,0); printf(%5s|,prefix); strcpy(tp,prefix); strcat(tp,6d|); printf(tp,I); strcpy(tp,); strcpy(tp,prefix); strcat(tp,6o|); printf(tp,I); strcpy(tp,); strcpy(tp,prefix); strcat(tp,8x|); printf(tp,
15、I); strcpy(tp,); strcpy(tp,prefix); strcat(tp,10.2e|); printf(tp,R); strcpy(tp,prefix); strcat(tp,10.2f|); printf(tp,R); printf(n); strcpy(prefix,%); return0; 函数名:putc 功能:输出一字符到指定流中 用法:intputc(intch,FILE*stream); 程序例: #include intmain(void) charmsg=Helloworldn; inti=0; while(msgi) putc(msgi+,stdout)
16、; return0; 函数名:putch 功能:输出字符到控制台 用法:intputch(intch); 程序例: #include #include intmain(void) charch=0; printf(Inputastring:); while(ch!=r) ch=getch(); putch(ch); return0; 函数名:putchar 功能:在stdout上输出字符 用法:intputchar(intch); 程序例: #include /*definesomebox-drawingcharacters*/ #defineLEFT_TOP0xDA #defineRIGHT
17、_TOP0xBF #defineHORIZ0xC4 #defineVERT0xB3 #defineLEFT_BOT0xC0 #defineRIGHT_BOT0xD9 intmain(void) chari,j; /*drawthetopofthebox*/ putchar(LEFT_TOP); for(i=0;i10;i+) putchar(HORIZ); putchar(RIGHT_TOP); putchar(n); /*drawthemiddle*/ for(i=0;i4;i+) putchar(VERT); for(j=0;j10;j+) putchar(); putchar(VERT)
18、; putchar(n); /*drawthebottom*/ putchar(LEFT_BOT); for(i=0;i10;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; /*getthecurrentpathenvironment*/ pt
19、r=getenv(PATH); /*setupnewpath*/ path=malloc(strlen(ptr)+15); strcpy(path,PATH=); strcat(path,ptr); strcat(path,;c:temp); /*replacethecurrentpathanddisplaycurrentenvironment*/ putenv(path); while(environi) printf(%sn,environi+); return0; 函数名:putimage 功能:在屏幕上输出一个位图 用法:voidfarputimage(intx,inty,voidfar*bitmap,intop); 程序例: #include #include #include #include #defineARROW_SIZE10 voiddraw_arrow(intx,inty); intmain(void) /*requestautodetection*/ intgdriver=DETECT,gmode,errorcode; void*arrow; intx,y,m
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1