如何解决代码块无法正常运行图形 c 程序 [英] how to solve codeblocks unable to run a graphics c program properly
问题描述
我为图形编程设置了代码块.就像我安装 winbgim 文件一样.并在代码块链接器设置中完成其他设置.但是当我运行这样的程序时
I had setup codeblocks for graphics programming. like I install winbgim file. and done other setup in the codeblocks linker setting. but when I ran a program like this
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
main(void) {
int gdriver = DETECT, gmode;
int x1 = 200, y1 = 200;
int x2 = 300, y2 = 300;
system("cls");
initgraph(&gdriver, &gmode, "");
line(x1, y1, x2, y2);
getch();
closegraph();
}
它没有像我预期的那样运行.由 0xc0000005 返回的进程.而且winbgi窗口也没有打开.所以请帮我解决这个问题
it did not run as I expected .the process returned by 0xc0000005 . and also the winbgi window did not opened. so plz help me to out of this problem
推荐答案
我遇到了同样的问题.您是否从其网站下载了 WinBGIm 库?
I faced the same issue. Did you download WinBGIm library from its website?
如果是,则头文件 graphics.h
和 winbgim.h
有错误.在第 302 行,在每个文件中,将 right = 0
替换为 top = 0
.
If yes, then the header files graphics.h
and winbgim.h
have a bug. On line 302, of each of those files, replace right = 0
with top = 0
.
但是,问题是库本身是使用有问题的"头文件构建的,所以:
But, then the problem is the library itself was built using the "buggy" header files, so:
- 您要么需要自己从源代码构建库,要么
- 您需要下载已由遇到此问题的其他人构建的更正库.幸运的是,我在这里找到了这样一个库a>(步骤 2 中的链接).
- you either need to build the library from the source code yourself, or
- you need to download corrected library which was already built by someone else who faced this issue. Fortunately, I found such a library here (Link in Step 2).
所以,现在如果您将更正的文件(头文件以及库)放入目标文件夹并重新构建,程序应该不会崩溃.
So, now if you put the corrected files (header files as well as the library), in the target folders and re-build, the program should not crash.
这篇关于如何解决代码块无法正常运行图形 c 程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!