line函数

更新时间:02-02 教程 由 枝桠 分享

基本释义

功能:在指定两点间画一直线

原形:voidfarline(intx0,inty0,intx1,inty1);

头文件:graphics.h

参数:x0,y0为直线初始坐标,X1,Y1为末坐标

程序例:

#include"graphics.h"

#include"stdlib.h"

intmain(void)

{

/*requestautodetection*/

intgdriver=DETECT,gmode,errorcode;

intxmax,ymax;

/*initializegraphicsandlocalvariables*/

initgraph(&gdriver,&gmode,"");

/*readresultofinitialization*/

errorcode=graphresult();

/*anerroroccurred*/

if(errorcode!=grOk)

{

printf("Graphicserror:%s\n",

grapherrormsg(errorcode));

printf("Pressanykeytohalt:");

getch();

exit(1);

}

setcolor(getmaxcolor());

xmax=getmaxx();

ymax=getmaxy();

/*drawadiagonalline*/

line(0,0,xmax,ymax);

/*cleanup*/

getch();

closegraph();/*关闭图形模式*/

return0;

}

#line

命令#line改变__LINE__与__FILE__的内容,它们是在编译程序中预先定义的标识符。

命令的基本形式如下:

#linenumber["filename"]

其中的数字为任何正整数,可选的文件名为任意有效文件标识符。行号为源程序中当前行号,文件名为源文件的名字。命令#line主要用于调试及其它特殊应用。

声明:关于《line函数》以上内容仅供参考,若您的权利被侵害,请联系13825271@qq.com
本文网址:http://www.25820.com/tutorial/14_2163563.html