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

📄 fi.htm

📁 turbo c
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<P>&nbsp;&nbsp; /* install a user defined font file */<BR>&nbsp;&nbsp; userfont = installuserfont("USER.CHR");<P>&nbsp;&nbsp; /* check for any installation errors */<BR>&nbsp;&nbsp; checkerrors();<P>&nbsp;&nbsp; /* select the user font */<BR>&nbsp;&nbsp; settextstyle(userfont, HORIZ_DIR, 4);<P>&nbsp;&nbsp; /* output some text */<BR>&nbsp;&nbsp; outtextxy(midx, midy, "Testing!");<P>&nbsp;&nbsp; /* clean up */<BR>&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; closegraph();<BR>&nbsp;&nbsp; return 0;<BR>}<P>/* check for and report any graphics errors */<BR>void checkerrors(void)<BR>{<BR>&nbsp;&nbsp; int errorcode;<P>&nbsp;&nbsp; /* read result of last graphics operation */<BR>&nbsp;&nbsp; errorcode = graphresult();<BR>&nbsp;&nbsp; if (errorcode != grOk)<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);<BR>&nbsp;&nbsp; }<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<P>函数名: int86<BR>功&nbsp; 能: 通用8086软中断接口<BR>用&nbsp; 法: int int86(int intr_num, union REGS *inregs, union REGS*outregs);<BR>程序例:<P>#include &lt;stdio.h><BR>#include &lt;conio.h><BR>#include &lt;dos.h><P>#define VIDEO 0x10<P>void movetoxy(int x, int y)<BR>{<BR>&nbsp;&nbsp; union REGS regs;<P>&nbsp;&nbsp; regs.h.ah = 2;&nbsp; /* set cursor postion */<BR>&nbsp;&nbsp; regs.h.dh = y;<BR>&nbsp;&nbsp; regs.h.dl = x;<BR>&nbsp;&nbsp; regs.h.bh = 0;&nbsp; /* video page 0 */<BR>&nbsp;&nbsp; int86(VIDEO, &amp;regs, &amp;regs);<BR>}<P>int main(void)<BR>{<BR>&nbsp;&nbsp; clrscr();<BR>&nbsp;&nbsp; movetoxy(35, 10);<BR>&nbsp;&nbsp; printf("Hello\n");<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: int86x<BR>功&nbsp; 能: 通用8086软中断接口<BR>用&nbsp; 法: int int86x(int intr_num, union REGS *insegs, union REGS*outregs,<BR>&nbsp;&nbsp;&nbsp;&nbsp; struct SREGS *segregs);<BR>程序例:<P>#include &lt;dos.h><BR>#include &lt;process.h><BR>#include &lt;stdio.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; char filename[80];<BR>&nbsp;&nbsp; union REGS inregs, outregs;<BR>&nbsp;&nbsp; struct SREGS segregs;<P>&nbsp;&nbsp; printf("Enter filename: ");<BR>&nbsp;&nbsp; gets(filename);<BR>&nbsp;&nbsp; inregs.h.ah = 0x43;<BR>&nbsp;&nbsp; inregs.h.al = 0x21;<BR>&nbsp;&nbsp; inregs.x.dx = FP_OFF(filename);<BR>&nbsp;&nbsp; segregs.ds = FP_SEG(filename);<BR>&nbsp;&nbsp; int86x(0x21, &amp;inregs, &amp;outregs, &amp;segregs);<BR>&nbsp;&nbsp; printf("File attribute: %X\n", outregs.x.cx);<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<P>函数名: intdos<BR>功&nbsp; 能: 通用DOS接口<BR>用&nbsp; 法: int intdos(union REGS *inregs, union REGS *outregs);<BR>程序例:<P>#include &lt;stdio.h><BR>#include &lt;dos.h><P>/* deletes file name; returns 0 on success, nonzero on failure */<BR>int delete_file(char near *filename)<BR>{<BR>&nbsp;&nbsp; union REGS regs;<BR>&nbsp;&nbsp; int ret;<BR>&nbsp;&nbsp; regs.h.ah = 0x41;&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;/* delete file */<BR>&nbsp;&nbsp; regs.x.dx = (unsigned) filename;<BR>&nbsp;&nbsp; ret = intdos(&amp;regs, &amp;regs);<P>&nbsp;&nbsp; /* if carry flag is set, there was an error */<BR>&nbsp;&nbsp; return(regs.x.cflag ? ret : 0);<BR>}<P>int main(void)<BR>{<BR>&nbsp;&nbsp; int err;<BR>&nbsp;&nbsp; err = delete_file("NOTEXIST.$$$");<BR>&nbsp;&nbsp; if (!err)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Able to delete NOTEXIST.$$$\n");<BR>&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Not Able to delete NOTEXIST.$$$\n");<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<P>函数名: intdosx<BR>功&nbsp; 能: 通用DOS中断接口<BR>用&nbsp; 法: int intdosx(union REGS *inregs, union REGS *outregs,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct SREGS *segregs);<BR>程序例:<P>#include &lt;stdio.h><BR>#include &lt;dos.h><P>/* deletes file name; returns 0 on success, nonzero on failure */<BR>int delete_file(char far *filename)<BR>{<BR>&nbsp;&nbsp; union REGS regs; struct SREGS sregs;<BR>&nbsp;&nbsp; int ret;<BR>&nbsp;&nbsp; regs.h.ah = 0x41;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* delete file */<BR>&nbsp;&nbsp; regs.x.dx = FP_OFF(filename);<BR>&nbsp;&nbsp; sregs.ds = FP_SEG(filename);<BR>&nbsp;&nbsp; ret = intdosx(&amp;regs, &amp;regs, &amp;sregs);<P>&nbsp;&nbsp; /* if carry flag is set, there was an error */<BR>&nbsp;&nbsp; return(regs.x.cflag ? ret : 0);<BR>}<P>int main(void)<BR>{<BR>&nbsp;&nbsp; int err;<BR>&nbsp;&nbsp; err = delete_file("NOTEXIST.$$$");<BR>&nbsp;&nbsp; if (!err)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Able to delete NOTEXIST.$$$\n");<BR>&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Not Able to delete NOTEXIST.$$$\n");<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: intr<BR>功&nbsp; 能: 改变软中断接口<BR>用&nbsp; 法: void intr(int intr_num, struct REGPACK *preg);<BR>程序例:<P>#include &lt;stdio.h><BR>#include &lt;string.h><BR>#include &lt;dir.h><BR>#include &lt;dos.h><P>#define CF 1&nbsp; /* Carry flag */<P>int main(void)<BR>{<BR>&nbsp;&nbsp; char directory[80];<BR>&nbsp;&nbsp; struct REGPACK reg;<P>&nbsp;&nbsp; printf("Enter directory to change to: ");<BR>&nbsp;&nbsp; gets(directory);<BR>&nbsp;&nbsp; reg.r_ax = 0x3B &lt;&lt; 8;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* shift 3Bh into&nbsp; AH */<BR>&nbsp;&nbsp; reg.r_dx = FP_OFF(directory);<BR>&nbsp;&nbsp; reg.r_ds = FP_SEG(directory);<BR>&nbsp;&nbsp; intr(0x21, &amp;reg);<BR>&nbsp;&nbsp; if (reg.r_flags &amp; CF)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Directory change failed\n");<BR>&nbsp;&nbsp; getcwd(directory, 80);<BR>&nbsp;&nbsp; printf("The current directory is: %s\n", directory);<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: ioctl<BR>功&nbsp; 能: 控制I/O设备<BR>用&nbsp; 法: int ioctl(int handle, int cmd[,int *argdx, int argcx]);<BR>程序例:<P>#include &lt;stdio.h><BR>#include &lt;dir.h><BR>#include &lt;io.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; int stat;<P>&nbsp;&nbsp; /* use func 8 to determine if the default drive is removable*/<BR>&nbsp;&nbsp; stat = ioctl(0, 8, 0, 0);<BR>&nbsp;&nbsp; if (!stat)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Drive %c is removable.\n", getdisk()+ 'A');<BR>&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Drive %c is not removable.\n",getdisk() + 'A');<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<P>函数名: isatty<BR>功&nbsp; 能: 检查设备类型<BR>用&nbsp; 法: int isatty(int handle);<BR>程序例:<P>#include &lt;stdio.h><BR>#include &lt;io.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; int handle;<P>&nbsp;&nbsp; handle = fileno(stdprn);<BR>&nbsp;&nbsp; if (isatty(handle))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Handle %d is a device type\n",handle);<BR>&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Handle %d isn't a device type\n",handle);<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<P>函数名: itoa<BR>功&nbsp; 能: 把一整数转换为字符串<BR>用&nbsp; 法: char *itoa(int value, char *string, int radix);<BR>程序例:<P>#include &lt;stdlib.h><BR>#include &lt;stdio.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; int number = 12345;<BR>&nbsp;&nbsp; char string[25];<P>&nbsp;&nbsp; itoa(number, string, 10);<BR>&nbsp;&nbsp; printf("integer = %d string = %s\n", number, string);<BR>&nbsp;&nbsp; return 0;<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><BR>&nbsp;<P></BODY></HTML>

⌨️ 快捷键说明

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