?? fi.htm
字號:
<P> /* install a user defined font file */
<BR> userfont = installuserfont("USER.CHR");
<P> /* check for any installation errors */
<BR> checkerrors();
<P> /* select the user font */
<BR> settextstyle(userfont, HORIZ_DIR, 4);
<P> /* output some text */
<BR> outtextxy(midx, midy, "Testing!");
<P> /* clean up */
<BR> getch();
<BR> closegraph();
<BR> return 0;
<BR>}
<P>/* check for and report any graphics errors */
<BR>void checkerrors(void)
<BR>{
<BR> int errorcode;
<P> /* read result of last graphics operation */
<BR> errorcode = graphresult();
<BR> if (errorcode != grOk)
<BR> {
<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));
<BR> printf("Press any key to halt:");
<BR> getch();
<BR> exit(1);
<BR> }
<BR> }
<BR>
<BR>
<BR>
<P>函數名: int86
<BR>功 能: 通用8086軟中斷接口
<BR>用 法: int int86(int intr_num, union REGS *inregs, union REGS
*outregs);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <conio.h>
<BR>#include <dos.h>
<P>#define VIDEO 0x10
<P>void movetoxy(int x, int y)
<BR>{
<BR> union REGS regs;
<P> regs.h.ah = 2; /* set cursor postion */
<BR> regs.h.dh = y;
<BR> regs.h.dl = x;
<BR> regs.h.bh = 0; /* video page 0 */
<BR> int86(VIDEO, &regs, &regs);
<BR>}
<P>int main(void)
<BR>{
<BR> clrscr();
<BR> movetoxy(35, 10);
<BR> printf("Hello\n");
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數名: int86x
<BR>功 能: 通用8086軟中斷接口
<BR>用 法: int int86x(int intr_num, union REGS *insegs, union REGS
*outregs,
<BR> struct SREGS *segregs);
<BR>程序例:
<P>#include <dos.h>
<BR>#include <process.h>
<BR>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> char filename[80];
<BR> union REGS inregs, outregs;
<BR> struct SREGS segregs;
<P> printf("Enter filename: ");
<BR> gets(filename);
<BR> inregs.h.ah = 0x43;
<BR> inregs.h.al = 0x21;
<BR> inregs.x.dx = FP_OFF(filename);
<BR> segregs.ds = FP_SEG(filename);
<BR> int86x(0x21, &inregs, &outregs, &segregs);
<BR> printf("File attribute: %X\n", outregs.x.cx);
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數名: intdos
<BR>功 能: 通用DOS接口
<BR>用 法: int intdos(union REGS *inregs, union REGS *outregs);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <dos.h>
<P>/* deletes file name; returns 0 on success, nonzero on failure */
<BR>int delete_file(char near *filename)
<BR>{
<BR> union REGS regs;
<BR> int ret;
<BR> regs.h.ah = 0x41;
/* delete file */
<BR> regs.x.dx = (unsigned) filename;
<BR> ret = intdos(&regs, &regs);
<P> /* if carry flag is set, there was an error */
<BR> return(regs.x.cflag ? ret : 0);
<BR>}
<P>int main(void)
<BR>{
<BR> int err;
<BR> err = delete_file("NOTEXIST.$$$");
<BR> if (!err)
<BR> printf("Able to delete NOTEXIST.$$$\n");
<BR> else
<BR> printf("Not Able to delete NOTEXIST.$$$\n");
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數名: intdosx
<BR>功 能: 通用DOS中斷接口
<BR>用 法: int intdosx(union REGS *inregs, union REGS *outregs,
<BR> struct SREGS *segregs);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <dos.h>
<P>/* deletes file name; returns 0 on success, nonzero on failure */
<BR>int delete_file(char far *filename)
<BR>{
<BR> union REGS regs; struct SREGS sregs;
<BR> int ret;
<BR> regs.h.ah = 0x41;
/* delete file */
<BR> regs.x.dx = FP_OFF(filename);
<BR> sregs.ds = FP_SEG(filename);
<BR> ret = intdosx(&regs, &regs, &sregs);
<P> /* if carry flag is set, there was an error */
<BR> return(regs.x.cflag ? ret : 0);
<BR>}
<P>int main(void)
<BR>{
<BR> int err;
<BR> err = delete_file("NOTEXIST.$$$");
<BR> if (!err)
<BR> printf("Able to delete NOTEXIST.$$$\n");
<BR> else
<BR> printf("Not Able to delete NOTEXIST.$$$\n");
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數名: intr
<BR>功 能: 改變軟中斷接口
<BR>用 法: void intr(int intr_num, struct REGPACK *preg);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <string.h>
<BR>#include <dir.h>
<BR>#include <dos.h>
<P>#define CF 1 /* Carry flag */
<P>int main(void)
<BR>{
<BR> char directory[80];
<BR> struct REGPACK reg;
<P> printf("Enter directory to change to: ");
<BR> gets(directory);
<BR> reg.r_ax = 0x3B << 8;
/* shift 3Bh into AH */
<BR> reg.r_dx = FP_OFF(directory);
<BR> reg.r_ds = FP_SEG(directory);
<BR> intr(0x21, &reg);
<BR> if (reg.r_flags & CF)
<BR> printf("Directory change failed\n");
<BR> getcwd(directory, 80);
<BR> printf("The current directory is: %s\n", directory);
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數名: ioctl
<BR>功 能: 控制I/O設備
<BR>用 法: int ioctl(int handle, int cmd[,int *argdx, int argcx]);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <dir.h>
<BR>#include <io.h>
<P>int main(void)
<BR>{
<BR> int stat;
<P> /* use func 8 to determine if the default drive is removable
*/
<BR> stat = ioctl(0, 8, 0, 0);
<BR> if (!stat)
<BR> printf("Drive %c is removable.\n", getdisk()
+ 'A');
<BR> else
<BR> printf("Drive %c is not removable.\n",
getdisk() + 'A');
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數名: isatty
<BR>功 能: 檢查設備類型
<BR>用 法: int isatty(int handle);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <io.h>
<P>int main(void)
<BR>{
<BR> int handle;
<P> handle = fileno(stdprn);
<BR> if (isatty(handle))
<BR> printf("Handle %d is a device type\n",
handle);
<BR> else
<BR> printf("Handle %d isn't a device type\n",
handle);
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數名: itoa
<BR>功 能: 把一整數轉換為字符串
<BR>用 法: char *itoa(int value, char *string, int radix);
<BR>程序例:
<P>#include <stdlib.h>
<BR>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> int number = 12345;
<BR> char string[25];
<P> itoa(number, string, 10);
<BR> printf("integer = %d string = %s\n", number, string);
<BR> return 0;
<BR>}
<BR>
<P>
<A HREF="index.html">返回目錄</A>
<BR>
<P>
</BODY>
</HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -