📄 fr.htm
字号:
<p>函数名: rectangle <br>
功 能: 画一个矩形 <br>
用 法: void far rectangle(int left, int top, int
right, int bottom); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int left, top, right, bottom; </p>
<p> /* initialize graphics and local
variables */ <br>
initgraph(&gdriver, &gmode,
""); </p>
<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>
<p> left = getmaxx() / 2 - 50; <br>
top = getmaxy() / 2 - 50; <br>
right = getmaxx() / 2 + 50; <br>
bottom = getmaxy() / 2 + 50; </p>
<p> /* draw a rectangle */ <br>
rectangle(left,top,right,bottom); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: registerbgidriver <br>
功 能:
登录已连接进来的图形驱动程序代码 <br>
用 法: int
registerbgidriver(void(*driver)(void)); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; </p>
<p> /* register a driver that was added into
graphics.lib */ <br>
errorcode =
registerbgidriver(EGAVGA_driver); </p>
<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 error code */ <br>
} </p>
<p> /* initialize graphics and local
variables */ <br>
initgraph(&gdriver, &gmode,
""); </p>
<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>
<p> /* draw a line */ <br>
line(0, 0, getmaxx(), getmaxy()); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: remove <br>
功 能: 删除一个文件 <br>
用 法: int remove(char *filename); <br>
程序例: </p>
<p>#include <stdio.h> </p>
<p>int main(void) <br>
{ <br>
char file[80]; </p>
<p> /* prompt for file name to delete */ <br>
printf("File to delete: "); <br>
gets(file); </p>
<p> /* delete the file */ <br>
if (remove(file) == 0) <br>
printf("Removed
%s.\n",file); <br>
else <br>
perror("remove"); </p>
<p> return 0; <br>
} <br>
<br>
</p>
<p>函数名: rename <br>
功 能: 重命名文件 <br>
用 法: int rename(char *oldname, char *newname); <br>
程序例: </p>
<p>#include <stdio.h> </p>
<p>int main(void) <br>
{ <br>
char oldname[80], newname[80]; </p>
<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>
<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>
<p> return 0; <br>
} <br>
<br>
</p>
<p>函数名: restorecrtmode <br>
功 能: 将屏幕模式恢复为先前的imitgraph设置
<br>
用 法: void far restorecrtmode(void); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int x, y; </p>
<p> /* initialize graphics and local
variables */ <br>
initgraph(&gdriver, &gmode,
""); </p>
<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>
<p> x = getmaxx() / 2; <br>
y = getmaxy() / 2; </p>
<p> /* output a message */ <br>
settextjustify(CENTER_TEXT, CENTER_TEXT); <br>
outtextxy(x, y, "Press any key to exit
graphics:"); <br>
getch(); </p>
<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>
<p> /* return to graphics mode */ <br>
setgraphmode(getgraphmode()); </p>
<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>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: rewind <br>
功 能:
将文件指针重新指向一个流的开头 <br>
用 法: int rewind(FILE *stream); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <dir.h> </p>
<p> int main(void) <br>
{ <br>
FILE *fp; <br>
char *fname = "TXXXXXX",
*newname, first; </p>
<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>
<p> return 0; <br>
} <br>
<br>
</p>
<p>函数名: rmdir <br>
功 能: 删除DOS文件目录 <br>
用 法: int rmdir(char *stream); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <conio.h> <br>
#include <process.h> <br>
#include <dir.h> </p>
<p>#define DIRNAME "testdir.$$$" </p>
<p>int main(void) <br>
{ <br>
int stat; </p>
<p> stat = mkdir(DIRNAME); <br>
if (!stat) <br>
printf("Directory created\n"); <br>
else <br>
{ <br>
printf("Unable to
create directory\n"); <br>
exit(1); <br>
} </p>
<p> getch(); <br>
system("dir/p"); <br>
getch(); </p>
<p> stat = rmdir(DIRNAME); <br>
if (!stat) <br>
printf("\nDirectory deleted\n"); <br>
else <br>
{ <br>
perror("\nUnable to delete
directory\n"); <br>
exit(1); <br>
} </p>
<p> return 0; <br>
} <br>
</p>
</td>
</tr>
</table>
</center></div><div align="center"><center>
<table border="0" cellspacing="1" width="640">
<tr>
<td class="p9" height="60"> <script>document.write("<p><a href=\"http://view.gznet.com/cgi-bin/rl_views.cgi?UID=10013421\" target=sxrl>");
document.write("<img src=\"http://refer.gznet.com/cgi-bin/rl_refer2.cgi?UID=10013421&refer="+escape(top.document.referrer)+"\" width=1 height=1 border=0 alt=\" \">");
document.write("</a>");
</script></td>
</tr>
</table>
</center></div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -