[英]Using graphics in code blocks but no output
I am a newbie regarding the use of graphics in programming. 我是有关在编程中使用图形的新手。 I have an experience with the non-graphics program though.
我在非图形程序方面有经验。 I am trying to run a graphics program in code blocks.
我试图在代码块中运行图形程序。 The code compiles successfully but the output is not displayed.
代码编译成功,但不显示输出。 I have copied the code from the web.
我已经从网上复制了代码。
#include<graphics.h>
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
int main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver, &gmode, "c:\turboc3\bgi");
//for head
ellipse(320,95,360,0,25,20);
line(298,85,341,85);
circle(310,90,2);
circle(330,90,2);
arc(320,100,200,-20,10);
//for neck
line(313,115,313,125);
line(328,115,328,125);
//For centre part
arc(320,225,72,107,100);
line(290,129,290,200);
line(350,129,350,200);
line(290,193,350,193);
line(290,200,350,200);
//for legs
line(290,200,285,280);
line(320,225,305,280);
line(322,225,335,280);
line(350,200,355,280);
//for right hand
line(290,129,255,165);
line(255,165,290,200);
line(290,149,275,165);
line(275,165,290,182);
//for left hand
line(350,129,385,165);
line(385,165,350,200);
line(350,149,365,165);
line(365,165,350,182);
//for shoes
line(285,280,275,287);
line(275,287,305,287);
line(305,280,305,287);
line(335,280,335,287);
line(335,287,365,287);
line(355,280,365,287);
//for name
settextstyle(2,HORIZ_DIR,4);
outtextxy(293,150,"The Crazy");
outtextxy(292,160,"Programmer");
getch();
closegraph();
}
This is the code I derived from this site. 这是我从衍生的代码此网站。 I have attached the output screen in case you wanna see my output.
如果您想查看我的输出,我已经附上了输出屏幕 。
Try Changing the path of BGI in initgraph() function. 尝试在initgraph()函数中更改BGI的路径。
initgraph(&gd,&gm,"\\Path to CodeBlocks Lib Folder");
and then run it. 然后运行它。
I hope it will work 我希望它能起作用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.