新人发帖,求指教!!!!
我下载的turbo c++3.0(颖思设计版的),我仿真它程序自带的“C语言库函数范例教程”中
的一个程序时(C语言库函数(R字母类)中的一个程序—>函数名:rectangle)程序如下:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int left, top, right, bottom;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
left = getmaxx() / 2 - 50;
top = getmaxy() / 2 - 50;
right = getmaxx() / 2 + 50;
bottom = getmaxy() / 2 + 50;
/* draw a rectangle */
rectangle(left,top,right,bottom);
/* clean up */
getch();
closegraph();
return 0;
}
编译连接时出现了很多(7条)错误,其中有一条就是:linking Error:Undefined symbol
_closegraph in modual
而头文件:<graphics.h> 中明明有这个函数,这里为什么会报错呢 turbo?c++
[解决办法]
应该是turbo c++3.0的环境问题,建议换个新的编译环境。
[解决办法]
而头文件:<graphics.h> 中明明有这个函数,这里为什么会报错呢
如果没有include头文件,会报undeclare错误
Undefined是说定义没找到,即需要指明它在哪个lib里
[解决办法]
#pragma comment(lib,"graphics")