📄 fm.htm
字号:
<P> getch();
<BR> system("dir");
<BR> getch();
<P> status = rmdir("asdfjklm");
<BR> (!status) ? (printf("Directory deleted\n")) :
<BR> (perror("Unable to delete directory"));
<P> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函数名: mktemp
<BR>功 能: 建立唯一的文件名
<BR>用 法: char *mktemp(char *template);
<BR>程序例:
<P>#include <dir.h>
<BR>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> /* fname defines the template for the
<BR> temporary file. */
<P> char *fname = "TXXXXXX", *ptr;
<P> ptr = mktemp(fname);
<BR> printf("%s\n",ptr);
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函数名: MK_FP
<BR>功 能: 设置一个远指针
<BR>用 法: void far *MK_FP(unsigned seg, unsigned off);
<BR>程序例:
<P>#include <dos.h>
<BR>#include <graphics.h>
<P>int main(void)
<BR>{
<BR> int gd, gm, i;
<BR> unsigned int far *screen;
<P> detectgraph(&gd, &gm);
<BR> if (gd == HERCMONO)
<BR> screen = MK_FP(0xB000, 0);
<BR> else
<BR> screen = MK_FP(0xB800, 0);
<BR> for (i=0; i<26; i++)
<BR> screen[i] = 0x0700 + ('a' + i);
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函数名: modf
<BR>功 能: 把数分为指数和尾数
<BR>用 法: double modf(double value, double *iptr);
<BR>程序例:
<P>#include <math.h>
<BR>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> double fraction, integer;
<BR> double number = 100000.567;
<P> fraction = modf(number, &integer);
<BR> printf("The whole and fractional parts of %lf are %lf
and %lf\n",
<BR> number, integer,
fraction);
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函数名: movedata
<BR>功 能: 拷贝字节
<BR>用 法: void movedata(int segsrc, int offsrc, int segdest,
<BR> int offdest, unsigned numbytes);
<BR>程序例:
<P>#include <mem.h>
<P>#define MONO_BASE 0xB000
<P>/* saves the contents of the monochrome screen in buffer */
<BR>void save_mono_screen(char near *buffer)
<BR>{
<BR> movedata(MONO_BASE, 0, _DS, (unsigned)buffer, 80*25*2);
<BR>}
<P>int main(void)
<BR>{
<BR> char buf[80*25*2];
<BR> save_mono_screen(buf);
<BR>}
<BR>
<BR>
<P>函数名: moverel
<BR>功 能: 将当前位置(CP)移动一相对距离
<BR>用 法: void far moverel(int dx, int dy);
<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> char msg[80];
<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> /* move the C.P. to location (20, 30) */
<BR> moveto(20, 30);
<P> /* plot a pixel at the C.P. */
<BR> putpixel(getx(), gety(), getmaxcolor());
<P> /* create and output a message at (20, 30) */
<BR> sprintf(msg, " (%d, %d)", getx(), gety());
<BR> outtextxy(20, 30, msg);
<P> /* move to a point a relative distance */
<BR> /* away from the current value of C.P. */
<BR> moverel(100, 100);
<P> /* plot a pixel at the C.P. */
<BR> putpixel(getx(), gety(), getmaxcolor());
<P> /* create and output a message at C.P. */
<BR> sprintf(msg, " (%d, %d)", getx(), gety());
<BR> outtext(msg);
<P> /* clean up */
<BR> getch();
<BR> closegraph();
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函数名: movetext
<BR>功 能: 将屏幕文本从一个矩形区域拷贝到另一个矩形区域
<BR>用 法: int movetext(int left, int top, int right, int bottom,
<BR> int newleft, int newtop);
<BR>程序例:
<BR>#include <conio.h>
<BR>#include <string.h>
<P>int main(void)
<BR>{
<BR> char *str = "This is a test string";
<P> clrscr();
<BR> cputs(str);
<BR> getch();
<P> movetext(1, 1, strlen(str), 2, 10, 10);
<BR> getch();
<P> return 0;
<BR>}
<BR>
<BR>
<P>函数名: moveto
<BR>功 能: 将CP移到(x, y)
<BR>用 法: void far moveto(int x, int y);
<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> char msg[80];
<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> /* move the C.P. to location (20, 30) */
<BR> moveto(20, 30);
<P> /* plot a pixel at the C.P. */
<BR> putpixel(getx(), gety(), getmaxcolor());
<P> /* create and output a message at (20, 30) */
<BR> sprintf(msg, " (%d, %d)", getx(), gety());
<BR> outtextxy(20, 30, msg);
<P> /* move to (100, 100) */
<BR> moveto(100, 100);
<P> /* plot a pixel at the C.P. */
<BR> putpixel(getx(), gety(), getmaxcolor());
<P> /* create and output a message at C.P. */
<BR> sprintf(msg, " (%d, %d)", getx(), gety());
<BR> outtext(msg);
<P> /* clean up */
<BR> getch();
<BR> closegraph();
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函数名: movemem
<BR>功 能: 移动一块字节
<BR>用 法: void movemem(void *source, void *destin, unsigned len);
<BR>程序例:
<P>#include <mem.h>
<BR>#include <alloc.h>
<BR>#include <stdio.h>
<BR>#include <string.h>
<P>int main(void)
<BR>{
<BR> char *source = "Borland International";
<BR> char *destination;
<BR> int length;
<P> length = strlen(source);
<BR> destination = malloc(length + 1);
<BR> movmem(source,destination,length);
<BR> printf("%s\n",destination);
<P> return 0;
<BR>}
<BR>
<BR>
<P>函数名: normvideo
<BR>功 能: 选择正常亮度字符
<BR>用 法: void normvideo(void);
<BR>程序例:
<P>#include <conio.h>
<P>int main(void)
<BR>{
<BR> normvideo();
<BR> cprintf("NORMAL Intensity Text\r\n");
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函数名: nosound
<BR>功 能: 关闭PC扬声器
<BR>用 法: void nosound(void);
<BR>程序例:
<P>/* Emits a 7-Hz tone for 10 seconds.
<P> True story: 7 Hz is the resonant frequency
of a chicken's skull cavity.
<BR> This was determined empirically in Australia,
where a new factory
<BR> generating 7-Hz tones was located too close
to a chicken ranch:
<BR> When the factory started up, all the chickens
died.
<P> Your PC may not be able to emit a 7-Hz tone.
<BR>*/
<P>int main(void)
<BR>{
<BR> sound(7);
<BR> delay(10000);
<BR> nosound();
<BR>}
<BR>
<P>
<A HREF="index.html">返回目录</A>
<P>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -