📄 fp.htm
字号:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<META NAME="Author" CONTENT="wdg">
<META NAME="GENERATOR" CONTENT="Mozilla/4.03 [en] (Win95; I) [Netscape]">
<TITLE>fp</TITLE>
</HEAD>
<BODY>
<P>函数名: parsfnm
<BR>功 能: 分析文件名
<BR>用 法: char *parsfnm (char *cmdline, struct fcb *fcbptr, int
option);
<BR>程序例:
<P>#include <process.h>
<BR>#include <string.h>
<BR>#include <stdio.h>
<BR>#include <dos.h>
<P>int main(void)
<BR>{
<BR> char line[80];
<BR> struct fcb blk;
<P> /* get file name */
<BR> printf("Enter drive and file name (no path - ie. a:file.dat)\n");
<BR> gets(line);
<P> /* put file name in fcb */
<BR> if (parsfnm(line, &blk, 1) == NULL)
<BR> printf("Error in parsfm call\n");
<BR> else
<BR> printf("Drive #%d Name: %11s\n",
blk.fcb_drive, blk.fcb_name);
<P> return 0;
<BR>}
<BR>
<BR>
<P>函数名: peek
<BR>功 能: 检查存储单元
<BR>用 法: int peek(int segment, unsigned offset);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <conio.h>
<BR>#include <dos.h>
<P>int main(void)
<BR>{
<BR> int value = 0;
<P> printf("The current status of your keyboard is:\n");
<BR> value = peek(0x0040, 0x0017);
<BR> if (value & 1)
<BR> printf("Right shift on\n");
<BR> else
<BR> printf("Right shift off\n");
<P> if (value & 2)
<BR> printf("Left shift on\n");
<BR> else
<BR> printf("Left shift off\n");
<P> if (value & 4)
<BR> printf("Control key on\n");
<BR> else
<BR> printf("Control key off\n");
<P> if (value & 8)
<BR> printf("Alt key on\n");
<BR> else
<BR> printf("Alt key off\n");
<P> if (value & 16)
<BR> printf("Scroll lock on\n");
<BR> else
<BR> printf("Scroll lock off\n");
<P> if (value & 32)
<BR> printf("Num lock on\n");
<BR> else
<BR> printf("Num lock off\n");
<P> if (value & 64)
<BR> printf("Caps lock on\n");
<BR> else
<BR> printf("Caps lock off\n");
<P> return 0;
<BR>}
<BR>
<BR>
<P>函数名: peekb
<BR>功 能: 检查存储单元
<BR>用 法: char peekb (int segment, unsigned offset);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <conio.h>
<BR>#include <dos.h>
<P>int main(void)
<BR>{
<BR> int value = 0;
<P> printf("The current status of your keyboard is:\n");
<BR> value = peekb(0x0040, 0x0017);
<BR> if (value & 1)
<BR> printf("Right shift on\n");
<BR> else
<BR> printf("Right shift off\n");
<P> if (value & 2)
<BR> printf("Left shift on\n");
<BR> else
<BR> printf("Left shift off\n");
<P> if (value & 4)
<BR> printf("Control key on\n");
<BR> else
<BR> printf("Control key off\n");
<P> if (value & 8)
<BR> printf("Alt key on\n");
<BR> else
<BR> printf("Alt key off\n");
<P> if (value & 16)
<BR> printf("Scroll lock on\n");
<BR> else
<BR> printf("Scroll lock off\n");
<P> if (value & 32)
<BR> printf("Num lock on\n");
<BR> else
<BR> printf("Num lock off\n");
<P> if (value & 64)
<BR> printf("Caps lock on\n");
<BR> else
<BR> printf("Caps lock off\n");
<P> return 0;
<BR>}
<BR>
<BR>
<P>函数名: perror
<BR>功 能: 系统错误信息
<BR>用 法: void perror(char *string);
<BR>程序例:
<P>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> FILE *fp;
<P> fp = fopen("perror.dat", "r");
<BR> if (!fp)
<BR> perror("Unable to open file for reading");
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函数名: pieslice
<BR>功 能: 绘制并填充一个扇形
<BR>用 法: void far pieslice(int x, int stanle, int endangle, int
radius);
<BR>程序例:
<P>#include <graphics.h>
<BR>#include <stdlib.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> /* request auto detection */
<BR> int gdriver = DETECT, gmode, errorcode;
<BR> int midx, midy;
<BR> int stangle = 45, endangle = 135, radius = 100;
<P> /* initialize graphics and local variables */
<BR> initgraph(&gdriver, &gmode, "");
<P> /* read result of initialization */
<BR> errorcode = graphresult();
<BR> if (errorcode != grOk) /* an error occurred */
<BR> {
<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));
<BR> printf("Press any key to halt:");
<BR> getch();
<BR> exit(1); /* terminate with an error
code */
<BR> }
<P> midx = getmaxx() / 2;
<BR> midy = getmaxy() / 2;
<P> /* set fill style and draw a pie slice */
<BR> setfillstyle(EMPTY_FILL, getmaxcolor());
<BR> pieslice(midx, midy, stangle, endangle, radius);
<P> /* clean up */
<BR> getch();
<BR> closegraph();
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函数名: poke
<BR>功 能: 存值到一个给定存储单元
<BR>用 法: void poke(int segment, int offset, int value);
<BR>程序例:
<P>#include <dos.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> clrscr();
<BR> cprintf("Make sure the scroll lock key is off and press
any key\r\n");
<BR> getch();
<BR> poke(0x0000,0x0417,16);
<BR> cprintf("The scroll lock is now on\r\n");
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函数名: pokeb
<BR>功 能: 存值到一个给定存储单元
<BR>用 法: void pokeb(int segment, int offset, char value);
<BR>程序例:
<P>#include <dos.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> clrscr();
<BR> cprintf("Make sure the scroll lock key is off and press
any key\r\n");
<BR> getch();
<BR> pokeb(0x0000,0x0417,16);
<BR> cprintf("The scroll lock is now on\r\n");
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函数名: poly
<BR>功 能: 根据参数产生一个多项式
<BR>用 法: double poly(double x, int n, double c[]);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <math.h>
<P>/* polynomial: x**3 - 2x**2 + 5x - 1 */
<P>int main(void)
<BR>{
<BR> double array[] = { -1.0, 5.0, -2.0, 1.0 };
<BR> double result;
<P> result = poly(2.0, 3, array);
<BR> printf("The polynomial: x**3 - 2.0x**2 + 5x - 1 at 2.0
is %lf\n",
<BR> result);
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函数名: pow
<BR>功 能: 指数函数(x的y次方)
<BR>用 法: double pow(double x, double y);
<BR>程序例:
<P>#include <math.h>
<BR>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> double x = 2.0, y = 3.0;
<P> printf("%lf raised to %lf is %lf\n", x, y, pow(x, y));
<BR> return 0;
<BR>}
<BR>
<P>函数名: pow10
<BR>功 能: 指数函数(10的p次方)
<BR>用 法: double pow10(int p);
<BR>程序例:
<P>#include <math.h>
<BR>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> double p = 3.0;
<P> printf("Ten raised to %lf is %lf\n", p, pow10(p));
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函数名: printf
<BR>功 能: 产生格式化输出的函数
<BR>用 法: int printf(char *format...);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <string.h>
<P>#define I 555
<BR>#define R 5.5
<P>int main(void)
<BR>{
<BR> int i,j,k,l;
<BR> char buf[7];
<BR> char *prefix = buf;
<BR> char tp[20];
<BR> printf("prefix 6d
6o 8x
10.2e "
<BR> "10.2f\n");
<BR> strcpy(prefix,"%");
<BR> for (i = 0; i < 2; i++)
<BR> {
<BR> for (j = 0; j < 2; j++)
<BR> for (k = 0; k <
2; k++)
<BR> for (l = 0; l < 2; l++)
<BR>
{
<BR>
if (i==0) strcat(prefix,"-");
<BR>
if (j==0) strcat(prefix,"+");
<BR>
if (k==0) strcat(prefix,"#");
<BR>
if (l==0) strcat(prefix,"0");
<BR>
printf("%5s |",prefix);
<BR>
strcpy(tp,prefix);
<BR>
strcat(tp,"6d |");
<BR>
printf(tp,I);
<BR>
strcpy(tp,"");
<BR>
strcpy(tp,prefix);
<BR>
strcat(tp,"6o |");
<BR>
printf(tp,I);
<BR>
strcpy(tp,"");
<BR>
strcpy(tp,prefix);
<BR>
strcat(tp,"8x |");
<BR>
printf(tp,I);
<BR>
strcpy(tp,"");
<BR>
strcpy(tp,prefix);
<BR> strcat(tp,"10.2e |");
<BR> printf(tp,R);
<BR> strcpy(tp,prefix);
<BR> strcat(tp,"10.2f |");
<BR> printf(tp,R);
<BR> printf(" \n");
<BR> strcpy(prefix,"%");
<BR> }
<BR> }
<BR> return 0;
<BR>}
<BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -