c++ - 在代码块中使用图形但没有输出
问题描述
我是关于在编程中使用图形的新手。不过,我有使用非图形程序的经验。我正在尝试在代码块中运行图形程序。代码编译成功,但不显示输出。我从网上复制了代码。
#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();
}
解决方案
尝试在 initgraph() 函数中更改 BGI 的路径。
initgraph(&gd,&gm,"\\Path to CodeBlocks Lib Folder");
然后运行它。
我希望它会工作
推荐阅读
- angular - 为什么在 Angular 9/ivy 编译器中不再需要 entryComponents?
- c++ - 在 char 数组中的空格后添加空格
- python - Pywin32 Outlook 限制功能停止工作
- java - 无法注入默认 MySQL 数据源
- python - 如何在 python 中将 HASHLIB 摘要转换为数组?
- python - 从python中的驱动器加载所有具有不同名称的图像
- java - 如何在Android(java或kotlin)中将多个数组与相同的第一个或最后一个元素组合?
- java - 如何通过 JavaFx CSS 使用自定义字体?
- iis - .Net Core 项目对 iis 中的高流量没有响应
- containers - 是否可以为 Service Fabric 来宾可执行文件和 Service Fabric 容器配置自动缩放?