⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fm.htm

📁 汇编&c语言code
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<P>&nbsp;&nbsp; getch();
<BR>&nbsp;&nbsp; system("dir");
<BR>&nbsp;&nbsp; getch();

<P>&nbsp;&nbsp; status = rmdir("asdfjklm");
<BR>&nbsp;&nbsp; (!status) ? (printf("Directory deleted\n")) :
<BR>&nbsp; (perror("Unable to delete directory"));

<P>&nbsp;&nbsp; return 0;
<BR>}
<BR>&nbsp;
<BR>&nbsp;
<BR>&nbsp;

<P>函数名: mktemp
<BR>功&nbsp; 能: 建立唯一的文件名
<BR>用&nbsp; 法: char *mktemp(char *template);
<BR>程序例:

<P>#include &lt;dir.h>
<BR>#include &lt;stdio.h>

<P>int main(void)
<BR>{
<BR>&nbsp;&nbsp; /* fname defines the template for the
<BR>&nbsp;&nbsp;&nbsp;&nbsp; temporary file.&nbsp; */

<P>&nbsp;&nbsp; char *fname = "TXXXXXX", *ptr;

<P>&nbsp;&nbsp; ptr = mktemp(fname);
<BR>&nbsp;&nbsp; printf("%s\n",ptr);
<BR>&nbsp;&nbsp; return 0;
<BR>}
<BR>&nbsp;
<BR>&nbsp;

<P>函数名: MK_FP
<BR>功&nbsp; 能: 设置一个远指针
<BR>用&nbsp; 法: void far *MK_FP(unsigned seg, unsigned off);
<BR>程序例:

<P>#include &lt;dos.h>
<BR>#include &lt;graphics.h>

<P>int main(void)
<BR>{
<BR>&nbsp;&nbsp; int gd, gm, i;
<BR>&nbsp;&nbsp; unsigned int far *screen;

<P>&nbsp;&nbsp; detectgraph(&amp;gd, &amp;gm);
<BR>&nbsp;&nbsp; if (gd == HERCMONO)
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; screen = MK_FP(0xB000, 0);
<BR>&nbsp;&nbsp; else
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; screen = MK_FP(0xB800, 0);
<BR>&nbsp;&nbsp; for (i=0; i&lt;26; i++)
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; screen[i] = 0x0700 + ('a' + i);
<BR>&nbsp;&nbsp; return 0;
<BR>}
<BR>&nbsp;
<BR>&nbsp;

<P>函数名: modf
<BR>功&nbsp; 能: 把数分为指数和尾数
<BR>用&nbsp; 法: double modf(double value, double *iptr);
<BR>程序例:

<P>#include &lt;math.h>
<BR>#include &lt;stdio.h>

<P>int main(void)
<BR>{
<BR>&nbsp;&nbsp; double fraction, integer;
<BR>&nbsp;&nbsp; double number = 100000.567;

<P>&nbsp;&nbsp; fraction = modf(number, &amp;integer);
<BR>&nbsp;&nbsp; printf("The whole and fractional parts of %lf are %lf
and %lf\n",
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; number, integer,
fraction);
<BR>&nbsp;&nbsp; return 0;
<BR>}
<BR>&nbsp;
<BR>&nbsp;

<P>函数名: movedata
<BR>功&nbsp; 能: 拷贝字节
<BR>用&nbsp; 法: void movedata(int segsrc, int offsrc, int segdest,
<BR>&nbsp; int offdest, unsigned numbytes);
<BR>程序例:

<P>#include &lt;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>&nbsp;&nbsp; movedata(MONO_BASE, 0, _DS, (unsigned)buffer, 80*25*2);
<BR>}

<P>int main(void)
<BR>{
<BR>&nbsp;&nbsp; char buf[80*25*2];
<BR>&nbsp;&nbsp; save_mono_screen(buf);
<BR>}
<BR>&nbsp;
<BR>&nbsp;

<P>函数名: moverel
<BR>功&nbsp; 能: 将当前位置(CP)移动一相对距离
<BR>用&nbsp; 法: void far moverel(int dx, int dy);
<BR>程序例:

<P>#include &lt;graphics.h>
<BR>#include &lt;stdlib.h>
<BR>#include &lt;stdio.h>
<BR>#include &lt;conio.h>

<P>int main(void)
<BR>{
<BR>&nbsp;&nbsp; /* request auto detection */
<BR>&nbsp;&nbsp; int gdriver = DETECT, gmode, errorcode;
<BR>&nbsp;&nbsp; char msg[80];

<P>&nbsp;&nbsp; /* initialize graphics and local variables */
<BR>&nbsp;&nbsp; initgraph(&amp;gdriver, &amp;gmode, "");

<P>&nbsp;&nbsp; /* read result of initialization */
<BR>&nbsp;&nbsp; errorcode = graphresult();
<BR>&nbsp;&nbsp; if (errorcode != grOk)&nbsp; /* an error occurred */
<BR>&nbsp;&nbsp; {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Graphics error: %s\n", grapherrormsg(errorcode));
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Press any key to halt:");
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getch();
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1); /* terminate with an error
code */
<BR>&nbsp;&nbsp; }

<P>&nbsp;&nbsp; /* move the C.P. to location (20, 30) */
<BR>&nbsp;&nbsp; moveto(20, 30);

<P>&nbsp;&nbsp; /* plot a pixel at the C.P. */
<BR>&nbsp;&nbsp; putpixel(getx(), gety(), getmaxcolor());

<P>&nbsp;&nbsp; /* create and output a message at (20, 30) */
<BR>&nbsp;&nbsp; sprintf(msg, " (%d, %d)", getx(), gety());
<BR>&nbsp;&nbsp; outtextxy(20, 30, msg);

<P>&nbsp;&nbsp; /* move to a point a relative distance */
<BR>&nbsp;&nbsp; /* away from the current value of C.P. */
<BR>&nbsp;&nbsp; moverel(100, 100);

<P>&nbsp;&nbsp; /* plot a pixel at the C.P. */
<BR>&nbsp;&nbsp; putpixel(getx(), gety(), getmaxcolor());

<P>&nbsp;&nbsp; /* create and output a message at C.P. */
<BR>&nbsp;&nbsp; sprintf(msg, " (%d, %d)", getx(), gety());
<BR>&nbsp;&nbsp; outtext(msg);

<P>&nbsp;&nbsp; /* clean up */
<BR>&nbsp;&nbsp; getch();
<BR>&nbsp;&nbsp; closegraph();
<BR>&nbsp;&nbsp; return 0;
<BR>}
<BR>&nbsp;
<BR>&nbsp;

<P>函数名: movetext
<BR>功&nbsp; 能: 将屏幕文本从一个矩形区域拷贝到另一个矩形区域
<BR>用&nbsp; 法: int movetext(int left, int top, int right, int bottom,
<BR>&nbsp; int newleft, int newtop);
<BR>程序例:
<BR>#include &lt;conio.h>
<BR>#include &lt;string.h>

<P>int main(void)
<BR>{
<BR>&nbsp;&nbsp; char *str = "This is a test string";

<P>&nbsp;&nbsp; clrscr();
<BR>&nbsp;&nbsp; cputs(str);
<BR>&nbsp;&nbsp; getch();

<P>&nbsp;&nbsp; movetext(1, 1, strlen(str), 2, 10, 10);
<BR>&nbsp;&nbsp; getch();

<P>&nbsp;&nbsp; return 0;
<BR>}
<BR>&nbsp;
<BR>&nbsp;

<P>函数名: moveto
<BR>功&nbsp; 能: 将CP移到(x, y)
<BR>用&nbsp; 法: void far moveto(int x, int y);
<BR>程序例:

<P>#include &lt;graphics.h>
<BR>#include &lt;stdlib.h>
<BR>#include &lt;stdio.h>
<BR>#include &lt;conio.h>

<P>int main(void)
<BR>{
<BR>&nbsp;&nbsp; /* request auto detection */
<BR>&nbsp;&nbsp; int gdriver = DETECT, gmode, errorcode;
<BR>&nbsp;&nbsp; char msg[80];

<P>&nbsp;&nbsp; /* initialize graphics and local variables */
<BR>&nbsp;&nbsp; initgraph(&amp;gdriver, &amp;gmode, "");

<P>&nbsp;&nbsp; /* read result of initialization */
<BR>&nbsp;&nbsp; errorcode = graphresult();
<BR>&nbsp;&nbsp; if (errorcode != grOk)&nbsp; /* an error occurred */
<BR>&nbsp;&nbsp; {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Graphics error: %s\n", grapherrormsg(errorcode));
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Press any key to halt:");
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getch();
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1); /* terminate with an error
code */
<BR>&nbsp;&nbsp; }

<P>&nbsp;&nbsp; /* move the C.P. to location (20, 30) */
<BR>&nbsp;&nbsp; moveto(20, 30);

<P>&nbsp;&nbsp; /* plot a pixel at the C.P. */
<BR>&nbsp;&nbsp; putpixel(getx(), gety(), getmaxcolor());

<P>&nbsp;&nbsp; /* create and output a message at (20, 30) */
<BR>&nbsp;&nbsp; sprintf(msg, " (%d, %d)", getx(), gety());
<BR>&nbsp;&nbsp; outtextxy(20, 30, msg);

<P>&nbsp;&nbsp; /* move to (100, 100) */
<BR>&nbsp;&nbsp; moveto(100, 100);

<P>&nbsp;&nbsp; /* plot a pixel at the C.P. */
<BR>&nbsp;&nbsp; putpixel(getx(), gety(), getmaxcolor());

<P>&nbsp;&nbsp; /* create and output a message at C.P. */
<BR>&nbsp;&nbsp; sprintf(msg, " (%d, %d)", getx(), gety());
<BR>&nbsp;&nbsp; outtext(msg);

<P>&nbsp;&nbsp; /* clean up */
<BR>&nbsp;&nbsp; getch();
<BR>&nbsp;&nbsp; closegraph();
<BR>&nbsp;&nbsp; return 0;
<BR>}
<BR>&nbsp;
<BR>&nbsp;

<P>函数名: movemem
<BR>功&nbsp; 能: 移动一块字节
<BR>用&nbsp; 法: void movemem(void *source, void *destin, unsigned len);
<BR>程序例:

<P>#include &lt;mem.h>
<BR>#include &lt;alloc.h>
<BR>#include &lt;stdio.h>
<BR>#include &lt;string.h>

<P>int main(void)
<BR>{
<BR>&nbsp;&nbsp; char *source = "Borland International";
<BR>&nbsp;&nbsp; char *destination;
<BR>&nbsp;&nbsp; int length;

<P>&nbsp;&nbsp; length = strlen(source);
<BR>&nbsp;&nbsp; destination = malloc(length + 1);
<BR>&nbsp;&nbsp; movmem(source,destination,length);
<BR>&nbsp;&nbsp; printf("%s\n",destination);

<P>&nbsp;&nbsp; return 0;
<BR>}
<BR>&nbsp;
<BR>&nbsp;

<P>函数名: normvideo
<BR>功&nbsp; 能: 选择正常亮度字符
<BR>用&nbsp; 法: void normvideo(void);
<BR>程序例:

<P>#include &lt;conio.h>

<P>int main(void)
<BR>{
<BR>&nbsp;&nbsp; normvideo();
<BR>&nbsp;&nbsp; cprintf("NORMAL Intensity Text\r\n");
<BR>&nbsp;&nbsp; return 0;
<BR>}
<BR>&nbsp;
<BR>&nbsp;

<P>函数名: nosound
<BR>功&nbsp; 能: 关闭PC扬声器
<BR>用&nbsp; 法: void nosound(void);
<BR>程序例:

<P>/* Emits a 7-Hz tone for 10 seconds.

<P>&nbsp;&nbsp;&nbsp;&nbsp; True story: 7 Hz is the resonant frequency
of a chicken's skull cavity.
<BR>&nbsp;&nbsp;&nbsp;&nbsp; This was determined empirically in Australia,
where a new factory
<BR>&nbsp;&nbsp;&nbsp;&nbsp; generating 7-Hz tones was located too close
to a chicken ranch:
<BR>&nbsp;&nbsp;&nbsp;&nbsp; When the factory started up, all the chickens
died.

<P>&nbsp;&nbsp;&nbsp;&nbsp; Your PC may not be able to emit a 7-Hz tone.
<BR>*/

<P>int main(void)
<BR>{
<BR>&nbsp;&nbsp; sound(7);
<BR>&nbsp;&nbsp; delay(10000);
<BR>&nbsp;&nbsp; nosound();
<BR>}
<BR>&nbsp;

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<A HREF="index.html">返回目录</A>

<P>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -