複製鏈接
請複製以下鏈接發送給好友

line

(函數)

鎖定
line,是函數,是代碼
中文名
line
功 能
:在指定兩點間畫一直線
參    數
x0y0為直線初始座標X1Y1為末座標
頭文件
graphics.h

目錄

line基本釋義

原 形void far line(int x0, int y0, int x1, int y1)
程序例:
#include "graphics.h"
#include "stdlib.h"
int main(void)
{
/* request auto detection */
	int gdriver = DETECT, gmode, errorcode;
	int xmax, ymax;
/* initialize graphics and local variables */
	initgraph(&gdriver, &gmode, '''');
/* read result of initialization */
	errorcode = graphresult();
/* an error occurred */
	if (errorcode != grOk)
{
	printf("Graphics error: %s\n",
	grapherrormsg(errorcode));
	printf("Press any key to halt:");
	getch();
	exit(1);
}
	setcolor(getmaxcolor());
	xmax = getmaxx();
	ymax = getmaxy();
/* draw a diagonal line */
	line(0, 0, xmax, ymax);
/* clean up */
	getch();
	closegraph(); /*關閉圖形模式*/
	return 0;
}
#line
命令# line改變__LINE__ 與__FILE__的內容,它們是在編譯程序中預先定義的標識符
命令的基本形式如下:
# line number["filename"]
其中的數字為任何正整數,可選的文件名為任意有效文件標識符。行號為源程序中當前行號,文件名為源文件的名字。命令# line主要用於調試及其它特殊應用.

line舉例

例如,下面説明行計數從1 0 0開始;printf( ) 語句顯示數1 0 2,因為它是語句#line 100後的第3行。
#line 100 /* 初始化行計數器* /
main ( ) /* 行號100 */
{ /* 行號101 */
p r i n t f ( " % d \ n " ,__LINE__ ) ; /* 行號102 */
}遺傳學 長分散核因子