Cannot run c graphics programs

╄→尐↘猪︶ㄣ 提交于 2019-11-28 12:34:00

Turbo-C, much like my first girlfriend, will always have a special place in my heart.

But its time to let her go. She's not the same girl you remember, and just cannot keep up with modern times. She may have been hip and cool at the time, but she can't handle modern trends at all. Even 32-bit memory is a real challenge for her. You're a better man now, and deserve a real woman. Go find yourself a good Visual Studio, or a nice GCC environment.

I'm not saying you have to forget Turbo-C. I know she was your first and will always be magical, but put her pictures in a shoebox, and don't take them out more than once a year. Its time to move on, buddy.

It sounds like it can't detect what kind of graphics card you have. Try setting the graphdriver parameter to either VGA or IBM8514.

In Turbo c goto options->Linker->Liabraries-> add Graphics Library. It might help

I'm assuming that all the other prerequisites like linkers are satisfied.

Now, as we know the BGI folder is usually in the following path(i.e. if you've followed the default installation):

C:\TurboC++\disk\TurboC3\BGI

As you can see the BGI folder is inside "TurboC3" and not TC. So the code you need to put in your program is as follows,

initgraph(&gd, &gm, "C:\\TurboC3\\BGI");

I hope this helps :) Happy graphics programming :D

The first step in any graphics program is to initialize the graphics drivers on the computer using initgraph method of graphics.h library.

void initgraph(int *graphicsDriver, int *graphicsMode, char *driverDirectoryPath);

It initializes the graphics system by loading the passed graphics driver then changing the system into graphics mode. driverDirectoryPath : It specifies the directory path where graphics driver files (BGI files) are located. If directory path is not provided, then it will seach for driver files in current working directory directory. Sample initialization statement

initgraph(&gd, &gm, "C:\\TC\\BGI");

Here is a list of C graphics program for reference :http://www.techcrashcourse.com/2015/08/c-graphics-programming-tutorial.html

Additionally, you can try using DOSBOX to run C graphics programs in Windows OS. I tried DOSBOX and it works smoothly in Windows. Here is one C graphics program which I tried using DOS Box http://www.techcrashcourse.com/2015/08/c-program-bouncing-ball-animation-graphics.html

you need to initialize the graphics function first. below is the code to initialize.

int gd=DETECT,gm; initgraph(&gd,&gm,"c:\\tc\\bgi");

this will initialize the graphics.

The Steps to make your TC able to run graphics program are as follows:

  1. copy CGA.BGI and EGAVGA.BGI files from TC\BGI folder and paste them in TC\BIN directory.

  2. Open TC by clicking on TC\BIN\TC.EXE.

  3. Click on Options -> Linker -> Libraries .

  4. Select the Graphics Library option and Press OK.

  5. Now you can compile your graphics program with Zero Compilation Errors.

Thanks!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!