




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、函数大全(p开头)函数名: 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、; 函数名: 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; 函数名: 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; 函数名: perror 功 能: 系统错误信息 用 法: 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; 函数名: 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; 函数名: 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; 函数名: 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; 函数名: poly 功 能: 根据参数产生一个多项式 用 法: 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; 函数名: pow 功 能: 指数函数(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; 函数名: pow10 功 能: 指数函数(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; 函数名: printf 功 &
42、#160;能: 产生格式化输出的函数 用 法: 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; 函数名: 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; 函数名: 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; 函数名: 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; 函数名: putenv 功 能: 把字符串加到当前环境中 用 法: 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; 函数名: 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; 函数名: 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; 函数名: 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; 函数名: puttext 功 能: 将文本从存储区拷贝到屏幕 用 法: int puttext(int left, int top, int right, int bott
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年银行金融类-金融考试-银行业专业人员中级(法规+公司信贷)历年参考题库典型考点含答案解析
- 2025年职业技能鉴定-石雕工-石雕工(中级)历年参考题库含答案解析(5套)
- 2025年职业技能鉴定-灭火救援专业士兵-灭火救援专业士兵(中级)历年参考题库含答案解析(5套)
- 2025年综合评标专家-天津-天津综合评标专家(工程造价类)历年参考题库含答案解析(5套)
- 热电厂消防安全知识培训课件
- 热处理工艺及设备
- 孟子三章课件
- 肌萎缩侧索硬化延髓麻痹护理查房
- 婚姻理财知识培训课件
- 山西省五寨县2025年上半年公开招聘辅警试题含答案分析
- GB/T 10781.1-2006浓香型白酒
- 冀教版六年级英语上册课件Unit-2
- 轴孔用YX型密封圈规格尺寸
- 肾上腺疾病外科治疗
- 第9章探放水钻机及相关设备的安全使用.
- 水调歌头·游泳-课件
- 人教版三年级下册体育与健康教案(全册教学设计)
- 交通部农村公路建设标准指导意见
- 卫浴店面管理
- 清表施工方案4常用
- 广西壮族自治区尾矿库注销及小型尾矿库闭库工作指导意见
评论
0/150
提交评论