C图形库错误 [英] C Graphics Library Error
问题描述
我有以下代码:
#include< stdio.h>
#include< conio.h>
#include< math.h>
#include< graphics.h>
void main()
{
int gd = DETECT,gm;
int dx,dy,p,end;
float x1,x2,y1,y2,x,y;
initgraph(& gd,& gm,);
printf(\\\
输入x1的值:);
scanf(%f,& x1);
printf(\\\
输入y1的值:);
scanf(%f,& y1);
printf(\\\
输入x2的值:);
scanf(%f,& x2);
printf(\\\
输入y2的值:);
scanf(%f,& y2);
dx = abs(x1-x2);
dy = abs(y2-y1);
p = 2 * dy-dx;
if(x1> x2)
{
x = x2;
y = y2;
end = x1;
}
else
{
x = x1;
y = y1;
end = x2;
}
putpixel(x,y,10);
while(x {
x = x + 1;
if(p <0)
{
p = p + 2 * dy;
}
else
{
y = y + 1;
p = p + 2 *(dy-dx);
}
putpixel(x,y,10);
}
getch();
closegraph();
}
该代码主要用于创建一条线。但是当我运行这个程序时,我在控制台(我使用的是Ubuntu 10.04版本)中收到错误消息:
$ b test.c:2 :致命错误:conio.h:没有这样的文件或目录
编译终止。
test.c:2:致命错误:graphics.h:没有这样的文件或目录
编译已终止。
这是否意味着我必须添加一些lib到C路径?
预先感谢。
图形。 h
是古老的非标准接口,来自Borland环境,我猜想。
I have the following code :
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
int dx,dy,p,end;
float x1,x2,y1,y2,x,y;
initgraph(&gd,&gm,"");
printf("\nEnter the value of x1: ");
scanf("%f",&x1);
printf("\nEnter the value of y1: ");
scanf("%f",&y1);
printf("\nEnter the value of x2: ");
scanf("%f",&x2);
printf("\nEnter the value of y2: ");
scanf("%f",&y2);
dx=abs(x1-x2);
dy=abs(y2-y1);
p=2*dy-dx;
if(x1>x2)
{
x=x2;
y=y2;
end=x1;
}
else
{
x=x1;
y=y1;
end=x2;
}
putpixel(x,y,10);
while(x<end)
{
x=x+1;
if(p<0)
{
p=p+2*dy;
}
else
{
y=y+1;
p=p+2*(dy-dx);
}
putpixel(x,y,10);
}
getch();
closegraph();
}
The code is mainly for creating a line. But when I run this program I get error message in my console(I'm using Ubuntu 10.04 version) as :
test.c:2: fatal error: conio.h: No such file or directory
compilation terminated.
test.c:2: fatal error: graphics.h: No such file or directory
compilation terminated.
Is that mean I have to add some lib to C path?
Thanks in advance.
conio.h
and graphics.h
are ancient, non-standard interfaces that came from Borland environments I suppose.
这篇关于C图形库错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!