|
楼主 |
发表于 2004-5-9 05:31:24
|
显示全部楼层
<>函数名: linerel
功 能: 从当前位置点(CP)到与CP有一给定相对距离的点画一直线
用 法: void far linerel(int dx, int dy);
程序例: <>#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h> <>int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
char msg[80]; <P> /* initialize graphics and local variables */
initgraph(&gdriver, &gmode, ""); <P> /* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n",
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
} <P> /* move the C.P. to location (20, 30) */
moveto(20, 30); <P> /* create and output a
message at (20, 30) */
sprintf(msg, " (%d, %d)", getx(), gety());
outtextxy(20, 30, msg); <P> /* draw a line to a point a relative
distance away from the current
value of C.P. */
linerel(100, 100); <P> /* create and output a message at C.P. */
sprintf(msg, " (%d, %d)", getx(), gety());
outtext(msg); <P> /* clean up */
getch();
closegraph();
return 0;
}
</P> |
|