问题
I have developed a graphic program on a desktop system. But when I tried to run it on the hp compaq laptop it's not getting executed. I developed it using Turbo C. Then i tried writing a simple graphic program in Turbo C on the laptop, but the problem I am getting is in 'initgraph' statement it is unable to detect the driver.
Can you please tell me what might be the problem?
回答1:
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.
回答2:
It sounds like it can't detect what kind of graphics card you have. Try setting the graphdriver
parameter to either VGA
or IBM8514
.
回答3:
In Turbo c goto options->Linker->Liabraries-> add Graphics Library. It might help
回答4:
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
回答5:
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
回答6:
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.
回答7:
The Steps to make your TC able to run graphics program are as follows:
copy CGA.BGI and EGAVGA.BGI files from TC\BGI folder and paste them in TC\BIN directory.
Open TC by clicking on TC\BIN\TC.EXE.
Click on Options -> Linker -> Libraries .
Select the Graphics Library option and Press OK.
Now you can compile your graphics program with Zero Compilation Errors.
Thanks!
来源:https://stackoverflow.com/questions/2513133/cannot-run-c-graphics-programs