📄 fr.htm
字号:
<BR>}<BR> <BR> <P>函数名: rectangle<BR>功 能: 画一个矩形<BR>用 法: void far rectangle(int left, int top, int right, int bottom);<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 left, top, right, bottom;<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 errorcode */<BR> }<P> left = getmaxx() / 2 - 50;<BR> top = getmaxy() / 2 - 50;<BR> right = getmaxx() / 2 + 50;<BR> bottom = getmaxy() / 2 + 50;<P> /* draw a rectangle */<BR> rectangle(left,top,right,bottom);<P> /* clean up */<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <P>函数名: registerbgidriver<BR>功 能: 登录已连接进来的图形驱动程序代码<BR>用 法: int registerbgidriver(void(*driver)(void));<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;<P> /* register a driver that was added into graphics.lib */<BR> errorcode = registerbgidriver(EGAVGA_driver);<P> /* report any registration errors */<BR> if (errorcode < 0)<BR> {<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));<BR> printf("Press any key to halt:");<BR> getch();<BR> exit(1); /* terminate with an errorcode */<BR> }<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 errorcode */<BR> }<P> /* draw a line */<BR> line(0, 0, getmaxx(), getmaxy());<P> /* clean up */<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <P>函数名: remove<BR>功 能: 删除一个文件<BR>用 法: int remove(char *filename);<BR>程序例:<P>#include <stdio.h><P>int main(void)<BR>{<BR> char file[80];<P> /* prompt for file name to delete */<BR> printf("File to delete: ");<BR> gets(file);<P> /* delete the file */<BR> if (remove(file) == 0)<BR> printf("Removed %s.\n",file);<BR> else<BR> perror("remove");<P> return 0;<BR>}<BR> <BR> <P>函数名: rename<BR>功 能: 重命名文件<BR>用 法: int rename(char *oldname, char *newname);<BR>程序例:<P>#include <stdio.h><P>int main(void)<BR>{<BR> char oldname[80], newname[80];<P> /* prompt for file to rename and new name */<BR> printf("File to rename: ");<BR> gets(oldname);<BR> printf("New name: ");<BR> gets(newname);<P> /* Rename the file */<BR> if (rename(oldname, newname) == 0)<BR> printf("Renamed %s to %s.\n", oldname,newname);<BR> else<BR> perror("rename");<P> return 0;<BR>}<BR> <BR> <P>函数名: restorecrtmode<BR>功 能: 将屏幕模式恢复为先前的imitgraph设置<BR>用 法: void far restorecrtmode(void);<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 x, y;<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 errorcode */<BR> }<P> x = getmaxx() / 2;<BR> y = getmaxy() / 2;<P> /* output a message */<BR> settextjustify(CENTER_TEXT, CENTER_TEXT);<BR> outtextxy(x, y, "Press any key to exit graphics:");<BR> getch();<P> /* restore system to text mode */<BR> restorecrtmode();<BR> printf("We're now in text mode.\n");<BR> printf("Press any key to return to graphics mode:");<BR> getch();<P> /* return to graphics mode */<BR> setgraphmode(getgraphmode());<P> /* output a message */<BR> settextjustify(CENTER_TEXT, CENTER_TEXT);<BR> outtextxy(x, y, "We're back in graphics mode.");<BR> outtextxy(x, y+textheight("W"), "Press any key to halt:");<P> /* clean up */<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <P>函数名: rewind<BR>功 能: 将文件指针重新指向一个流的开头<BR>用 法: int rewind(FILE *stream);<BR>程序例:<P>#include <stdio.h><BR>#include <dir.h><P> int main(void)<BR> {<BR> FILE *fp;<BR> char *fname = "TXXXXXX", *newname, first;<P> newname = mktemp(fname);<BR> fp = fopen(newname,"w+");<BR> fprintf(fp,"abcdefghijklmnopqrstuvwxyz");<BR> rewind(fp);<BR> fscanf(fp,"%c",&first);<BR> printf("The first character is: %c\n",first);<BR> fclose(fp);<BR> remove(newname);<P> return 0;<BR>}<BR> <BR> <P>函数名: rmdir<BR>功 能: 删除DOS文件目录<BR>用 法: int rmdir(char *stream);<BR>程序例:<P>#include <stdio.h><BR>#include <conio.h><BR>#include <process.h><BR>#include <dir.h><P>#define DIRNAME "testdir.$$$"<P>int main(void)<BR>{<BR> int stat;<P> stat = mkdir(DIRNAME);<BR> if (!stat)<BR> printf("Directorycreated\n");<BR> else<BR> {<BR> printf("Unable to create directory\n");<BR> exit(1);<BR> }<P> getch();<BR> system("dir/p");<BR> getch();<P> stat = rmdir(DIRNAME);<BR> if (!stat)<BR> printf("\nDirectorydeleted\n");<BR> else<BR> {<BR> perror("\nUnable to delete directory\n");<BR> exit(1);<BR> }<P> return 0;<BR>}<BR> <P> <A HREF="index.html">返回目录</A><BR></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -