




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領
文檔簡介
1、函數(shù)大全(p開頭)函數(shù)名: parsfnm 功 能: 分析文件名 用 法: char *parsfnm (char *cmdline, struct fcb *fcbptr, int option); 程序例: #include <process.h> #include <string.h> #include <
2、stdio.h> #include <dos.h> int main(void) char line80; struct fcb blk; /* get file name */ printf("Enter drive and
3、0;file name (no path - ie. a:file.dat)n"); gets(line); /* put file name in fcb */ if (parsfnm(line, &blk, 1) = NULL)
4、; printf("Error in parsfm calln"); else printf("Drive #%d Name: %11sn", blk.fcb_drive, blk.fcb_name); return 0;
5、; 函數(shù)名: peek 功 能: 檢查存儲單元 用 法: int peek(int segment, unsigned offset); 程序例: #include <stdio.h> #include <conio.h> #include <dos.h> int
6、60;main(void) int value = 0; printf("The current status of your keyboard is:n"); value = peek(0x0040, 0x0017); if (value
7、160;& 1) printf("Right shift onn"); else printf("Right shift offn"); if (value & 2)
8、0; printf("Left shift onn"); else printf("Left shift offn"); if (value & 4) printf(&qu
9、ot;Control key onn"); else printf("Control key offn"); if (value & 8) printf("Alt key onn");
10、160; else printf("Alt key offn"); if (value & 16) printf("Scroll lock onn"); else
11、60; printf("Scroll lock offn"); if (value & 32) printf("Num lock onn"); else pri
12、ntf("Num lock offn"); if (value & 64) printf("Caps lock onn"); else printf("Caps lock offn&quo
13、t;); return 0; 函數(shù)名: peekb 功 能: 檢查存儲單元 用 法: char peekb (int segment, unsigned offset); 程序例: #include <stdio.h> #include <c
14、onio.h> #include <dos.h> int main(void) int value = 0; printf("The current status of your keyboard is:n"); value = peekb(0x00
15、40, 0x0017); if (value & 1) printf("Right shift onn"); else printf("Right shift offn");
16、0; if (value & 2) printf("Left shift onn"); else printf("Left shift offn"); if (value &
17、60;4) printf("Control key onn"); else printf("Control key offn"); if (value & 8)
18、0; printf("Alt key onn"); else printf("Alt key offn"); if (value & 16) printf("Scroll lo
19、ck onn"); else printf("Scroll lock offn"); if (value & 32) printf("Num lock onn");
20、0; else printf("Num lock offn"); if (value & 64) printf("Caps lock onn"); else &
21、#160; printf("Caps lock offn"); return 0; 函數(shù)名: perror 功 能: 系統(tǒng)錯誤信息 用 法: void perror(char *string); 程序例: #include <stdio.h&g
22、t; int main(void) FILE *fp; fp = fopen("perror.dat", "r"); if (!fp) perror("Unable to open file fo
23、r reading"); return 0; 函數(shù)名: pieslice 功 能: 繪制并填充一個扇形 用 法: void far pieslice(int x, int stanle, int endangle, int radius); 程
24、序例: #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> int main(void) /* request auto detection */ int gdriver
25、160;= DETECT, gmode, errorcode; int midx, midy; int stangle = 45, endangle = 135, radius = 100; /* initialize graphics and local vari
26、ables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); if (errorcode !=
27、;grOk) /* an error occurred */ printf("Graphics error: %sn", grapherrormsg(errorcode); printf("Press any key to
28、0;halt:"); getch(); exit(1); /* terminate with an error code */ midx = getmaxx() / 2;
29、60;midy = getmaxy() / 2; /* set fill style and draw a pie slice */ setfillstyle(EMPTY_FILL, getmaxcolor(); pieslice(midx, midy, stangle, endang
30、le, radius); /* clean up */ getch(); closegraph(); return 0; 函數(shù)名: poke 功 能: 存值到一個給定存儲單元 用 法:
31、0;void poke(int segment, int offset, int value); 程序例: #include <dos.h> #include <conio.h> int main(void) clrscr(); cprintf("Make sure the scroll
32、 lock key is off and press any keyrn"); getch(); poke(0x0000,0x0417,16); cprintf("The scroll lock is now onrn"); return
33、;0; 函數(shù)名: pokeb 功 能: 存值到一個給定存儲單元 用 法: void pokeb(int segment, int offset, char value); 程序例: #include <dos.h> #include <conio.h> int
34、main(void) clrscr(); cprintf("Make sure the scroll lock key is off and press any keyrn"); getch(); pokeb(0x0000,0x0417,16);
35、160; cprintf("The scroll lock is now onrn"); return 0; 函數(shù)名: poly 功 能: 根據(jù)參數(shù)產(chǎn)生一個多項式 用 法: double poly(double x, int n,
36、160;double c); 程序例: #include <stdio.h> #include <math.h> /* polynomial: x*3 - 2x*2 + 5x - 1 */ int main(void) double array = -1.0,
37、;5.0, -2.0, 1.0 double result; result = poly(2.0, 3, array); printf("The polynomial: x*3 - 2.0x*2 + 5x - 1 at 2.0 is %lfn&
38、quot;, result); return 0; 函數(shù)名: pow 功 能: 指數(shù)函數(shù)(x的y次方) 用 法: double pow(double x, double y);
39、60; 程序例: #include <math.h> #include <stdio.h> int main(void) double x = 2.0, y = 3.0; printf("%lf raised to %lf is %lfn", x,
40、y, pow(x, y); return 0; 函數(shù)名: pow10 功 能: 指數(shù)函數(shù)(10的p次方) 用 法: double pow10(int p); 程序例: #include <math.h> #include <stdio.h> int
41、main(void) double p = 3.0; printf("Ten raised to %lf is %lfn", p, pow10(p); return 0; 函數(shù)名: printf 功 &
42、#160;能: 產(chǎn)生格式化輸出的函數(shù) 用 法: int printf(char *format.); 程序例: #include <stdio.h> #include <string.h> #define I 555 #define R 5.5 int main(void) int i,
43、j,k,l; char buf7; char *prefix = buf; char tp20; printf("prefix 6d 6o 8x
44、60; 10.2e " "10.2fn"); strcpy(prefix,"%"); for (i = 0; i <
45、;2; i+) for (j = 0; j < 2; j+) for (k = 0; k < 2; k+) fo
46、r (l = 0; l < 2; l+) if (i=0) strcat(prefix,"-");
47、; if (j=0) strcat(prefix,"+"); if (k=0) strcat(prefix,"#");
48、60; if (l=0) strcat(prefix,"0"); printf("%5s |",prefix);
49、; strcpy(tp,prefix); strcat(tp,"6d |");
50、 printf(tp,I); strcpy(tp,""); strcpy(tp,prefix);
51、160; strcat(tp,"6o |"); printf(tp,I);
52、160;strcpy(tp,""); strcpy(tp,prefix); strcat(tp,"8x |");
53、160; printf(tp,I); strcpy(tp,"");
54、;strcpy(tp,prefix); strcat(tp,"10.2e |"); printf(tp,R); strcpy(tp,prefix);
55、 strcat(tp,"10.2f |"); printf(tp,R); printf(" n"); strcpy(prefix,"%");
56、0; return 0; 函數(shù)名: putc 功 能: 輸出一字符到指定流中 用 法: int putc(int ch, FILE *stream); 程序例: #in
57、clude <stdio.h> int main(void) char msg = "Hello worldn" int i = 0; while (msgi) putc(msgi+, stdout);&
58、#160; return 0; 函數(shù)名: putch 功 能: 輸出字符到控制臺 用 法: int putch(int ch); 程序例: #include <stdio.h> #include <conio.h> int main(void)
59、 char ch = 0; printf("Input a string:"); while (ch != 'r') ch = getch(); &
60、#160; putch(ch); return 0; 函數(shù)名: putchar 功 能: 在stdout上輸出字符 用 法: int putchar(int ch); 程序例: #include <stdio.h>&
61、#160; /* define some box-drawing characters */ #define LEFT_TOP 0xDA #define RIGHT_TOP 0xBF #define HORIZ 0xC4 #define VERT 0xB3 #define LEF
62、T_BOT 0xC0 #define RIGHT_BOT 0xD9 int main(void) char i, j; /* draw the top of the box */ putchar(LEFT_TOP); for
63、160;(i=0; i<10; i+) putchar(HORIZ); putchar(RIGHT_TOP); putchar('n'); /* draw the middle */ for (i=0; i<4;
64、160;i+) putchar(VERT); for (j=0; j<10; j+) putchar(' '); p
65、utchar(VERT); putchar('n'); /* draw the bottom */ putchar(LEFT_BOT); for (i=0; i<10; i+)
66、160; putchar(HORIZ); putchar(RIGHT_BOT); putchar('n'); return 0; 函數(shù)名: putenv 功 能: 把字符串加到當前環(huán)境中 用 法: int putenv(c
67、har *envvar); 程序例: #include <stdio.h> #include <stdlib.h> #include <alloc.h> #include <string.h> #include <dos.h> int main(void) char *path, *ptr;
68、 int i = 0; /* get the current path environment */ ptr = getenv("PATH"); /* set up new path */ p
69、ath = malloc(strlen(ptr)+15); strcpy(path,"PATH="); strcat(path,ptr); strcat(path,"c:temp"); /* replace the current path and display curren
70、t environment */ putenv(path); while (environi) printf("%sn",environi+); return 0; 函數(shù)名: putimage 功
71、160; 能: 在屏幕上輸出一個位圖 用 法: void far putimage(int x, int y, void far *bitmap, int op); 程序例: #include <graphics.h> #include <stdlib.h> #include <stdio.h> #inclu
72、de <conio.h> #define ARROW_SIZE 10 void draw_arrow(int x, int y); int main(void) /* request autodetection */ int gdriver = DETECT, gmode, err
73、orcode; void *arrow; int x, y, maxx; unsigned int size; /* initialize graphics and local variables */ initgraph(&gdr
74、iver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an error occurred
75、60;*/ printf("Graphics error: %sn", grapherrormsg(errorcode); printf("Press any key to halt:");
76、0;getch(); exit(1); /* terminate with an error code */ maxx = getmaxx(); x = 0; y = getmaxy()
77、60;/ 2; /* draw the image to be grabbed */ draw_arrow(x, y); /* calculate the size of the image */ size = imagesiz
78、e(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE); /* allocate memory to hold the image */ arrow = malloc(size); /* grab the image */ &
79、#160; getimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow); /* repeat until a key is pressed */ while (!kbhit()
80、160;/* erase old image */ putimage(x, y-ARROW_SIZE, arrow, XOR_PUT); x += ARROW_SIZE; if (x >= maxx)
81、0; x = 0; /* plot new image */ putimage(x, y-ARROW_SIZE, arrow, XOR_PUT); &
82、#160;/* clean up */ free(arrow); closegraph(); return 0; void draw_arrow(int x, int y) /* draw an arrow on the scr
83、een */ 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);&
84、#160; 函數(shù)名: putpixel 功 能: 在指定位置畫一像素 用 法: void far putpixel (int x, int y, int pixelcolor); 程序例: #include <graphics.h> #include <stdlib.h>
85、160; #include <stdio.h> #include <conio.h> #include <dos.h> #define PIXEL_COUNT 1000 #define DELAY_TIME 100 /* in milliseconds */ int main(void) /*
86、160;request autodetection */ int gdriver = DETECT, gmode, errorcode; int i, x, y, color, maxx, maxy, maxcolor, seed; /* initialize graphics
87、0;and local variables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); if
88、60;(errorcode != grOk) /* an error occurred */ printf("Graphics error: %sn", grapherrormsg(errorcode); printf("Press
89、0;any key to halt:"); getch(); exit(1); /* terminate with an error code */ maxx = getmaxx() +
90、0;1; maxy = getmaxy() + 1; maxcolor = getmaxcolor() + 1; while (!kbhit() /* seed the random numb
91、er generator */ seed = random(32767); srand(seed); for (i=0; i<PIXEL_COUNT; i+) &
92、#160;x = random(maxx); y = random(maxy); color = random(maxcolor); putpixel(x, y,
93、0;color); delay(DELAY_TIME); srand(seed); for (i=0; i<PIXEL_COUNT; i+)
94、 x = random(maxx); y = random(maxy); color = random(maxcolor); if (color = getpixel(x, y) putpixel(x, y, 0);
95、; /* clean up */ getch(); closegraph(); return 0; 函數(shù)名: puts 功 能: 送一字符串到流中
96、160; 用 法: int puts(char *string); 程序例: #include <stdio.h> int main(void) char string = "This is an example output stringn" puts(string); return 0; 函數(shù)名: puttext 功 能: 將文本從存儲區(qū)拷貝到屏幕 用 法: int puttext(int left, int top, int right, int bott
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 勞動力職業(yè)培訓管理制度
- 公司用品供應鏈管理制度
- 培訓機構(gòu)早教室管理制度
- 旅游廁所后續(xù)管理制度
- 施工項目責任管理制度
- 專職輔導員人事管理制度
- 幼兒園進出審批管理制度
- 景區(qū)索道設施管理制度
- 日常用電安全管理制度
- 培訓班防疫防控管理制度
- 莎士比亞戲劇賞析智慧樹知到期末考試答案章節(jié)答案2024年北京師范大學
- 飲食基因與文化智慧樹知到期末考試答案2024年
- (正式版)SHT 3046-2024 石油化工立式圓筒形鋼制焊接儲罐設計規(guī)范
- 2023年山東濟南市初中學業(yè)水平考試地理試卷真題(答案詳解)
- 國開??啤督ㄖ茍D基礎》形考作業(yè)1-4試題及答案
- GA/T 2015-2023芬太尼類藥物專用智能柜通用技術規(guī)范
- 志愿服務證明(多模板)
- 《銷售員的角色定位》課件
- 阿森斯失眠評定量表2
- 安全防水知識培訓內(nèi)容
- 梨生產(chǎn)技術規(guī)范
評論
0/150
提交評論