请教各位高手,怎样才能找到graphics.h???

laural24 2003-05-15 10:13:57
编译环境为vc++6.0,用它来编一个图形程序时,编译出错!

#include<graphics.h>
#include<math.h>
#include<conio.h>

const int MAX=100;
class picture
{int i,j,rad,x_center,y_center,points;
int x[MAX],y[MAX];
public:
picture(int,int,int,int);
void draw();
}
picture::picture(int xc,int yc,int r,int p)
{i=j=0;
rad=r;
x_center=xc;
y_center=yc;
points=p;
for(i=0;i<points;i++)
{x[i]=x_center+rad*cos(360/points*i*3.1415926/180);
y[i]=y_center+rad*sin(360/points*i*3.1415926/180);
}
}
void picture::draw()
{for(i=0;i<points;i++)
for(j=0;j<points;j++)
line(x[i],y[i],x[j],y[j]);
circle(x_center,y_center,rad);
}
void main()
{int driver=DETECT,mode;
picture A1(120,150,100,16);
picture A2(360,150,100,20);
picture A3(240,330,100,24);

initgraph(&driver,&mode,"c:\\vc\\bgi");
A1.draw();
A2.draw();
A3.draw();
getch();
closegraph();}


d:\111.cpp(1) : fatal error C1083: Cannot open include file: 'graphics.h': No such file or directory

为什么会这样?
...全文
123 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
icansaymyabc 2003-05-19
  • 打赏
  • 举报
回复
//给你改好了,VC版的。
//把它存为 A.cpp 一定要在VC6下编译.
#include<windows.h>
#include<math.h>
#include<conio.h>

HDC g_hdc;
void initgraph()
{
HPEN hpen=CreatePen(PS_SOLID,1,0x0000FFFF);
g_hdc=GetDC(NULL);
SelectObject(g_hdc,hpen);
}
void closegraph()
{
ReleaseDC(NULL,g_hdc);
}

void line(int x1, int y1, int x2, int y2)
{
MoveToEx(g_hdc,x1,y1,NULL);
LineTo(g_hdc,x2,y2);
}

void circle(int cx, int cy, int r)
{
Ellipse(g_hdc, cx-r,cy-r,cx+r,cy+r);
}

const int MAX=100;
class picture
{
int i,j,rad,x_center,y_center,points;
int x[MAX],y[MAX];
public:
picture(int,int,int,int);
void draw();
};

picture::picture(int xc,int yc,int r,int p)
{
i=j=0;
rad=r;
x_center=xc;
y_center=yc;
points=p;
for(i=0;i<points;i++)
{
x[i]=int(x_center+rad*cos(360/points*i*3.1415926/180));
y[i]=int(y_center+rad*sin(360/points*i*3.1415926/180));
}
}

void picture::draw()
{
for(i=0;i<points;i++)
for(j=0;j<points;j++)
line(x[i],y[i],x[j],y[j]);
// circle(x_center,y_center,rad);
}

void main()
{
picture A1(120,150,100,16);
picture A2(360,150,100,20);
picture A3(240,330,100,24);

initgraph();
A1.draw();
A2.draw();
A3.draw();
closegraph();
getch();
}
idau7 2003-05-19
  • 打赏
  • 举报
回复
up
scgjc 2003-05-19
  • 打赏
  • 举报
回复
up
meteor135 2003-05-19
  • 打赏
  • 举报
回复
楼上的程序的美中不足的是,当拖动了控制台窗口的滚动条后,原来画的图像就不见了。
怎么解决?
BeZyzz 2003-05-18
  • 打赏
  • 举报
回复
晕,有没有搞错啊,<graphics.h>是TC下的,VC,DEVC++等哪有什么<graphics.h>

你是不是在学校里刚开始学C语言啊?建议你除了TC以外,最好也试试其他编译器。
5will 2003-05-17
  • 打赏
  • 举报
回复
也想问一下
为什么在DEVC++中也不能用<graphics.h>
scgjc 2003-05-16
  • 打赏
  • 举报
回复
顺道提问:我的一本计算机图形学书上的一些例程里包含的头文件有一个"device.h",哪位高手的编译系统有这个头文件,告我一声。谢谢!
oneonone 2003-05-16
  • 打赏
  • 举报
回复
c与vc有很大的不同,c 的程序不能在vc上直接运行
lifanxi 2003-05-15
  • 打赏
  • 举报
回复
请换用TC或BC来编译运行您的程序,别用VC了。用BC时别忘了在Linker选项中把图形库选上,否则会链接错。
别找graphics.h了,就算你把BC的graphics.h复制到VC的目录下也没用,这不是一个头文件的问题,还涉及到库文件等一系列的问题。
brucegong 2003-05-15
  • 打赏
  • 举报
回复




VC不支持




24,860

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧