2

I am having trouble using graphics.h in code blocks.

I have installed winbgi. Edited 302nd line. Linked lib file and all that stuff is done. So, I don't have any error regarding graphics header file.

But whenever I run/build any code involving graphics functions, windows gives an error ".. has stopped working". How to fix this?

I am using Codeblock v16. Windows 7ultimate - 64bit.

Here is my code:

#include<graphics.h>
int main() {
   int gd = DETECT,gm;

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

   line(80, 100, 100, 100);
   getch();
   //return 0;
}

screenshots:

screenshot of codeblock window

Screenshot of Error window

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • when you use of graphic mode in c, output window will changed to fullscreen mode, and in windows 7 you cannot fullscreen cmd window. else use of dosbox program. i hope this can help you. – BattleTested_закалённый в бою Jun 06 '16 at 08:30
  • Thanks you for your comment. I don't mind if its not fullscreen. I need to run graphic programs. Is it possible? I have added screenshot[edited], please go through those. – LearningSinceBigBang Jun 06 '16 at 08:50
  • This error windows is generally generated when there is a run time error!! – mssirvi Jun 06 '16 at 10:21
  • @LearningSinceBigBang if you want change to fullscreen mode, you must install DosBox program, then run your c code in dosbox. – BattleTested_закалённый в бою Jun 06 '16 at 11:00
  • @MohammadrezaPanahi Can you please help me to do that? But actually I am not botherd about screen size. I just wanna keep same size and run graphic programs.. Is that possible? – LearningSinceBigBang Jun 06 '16 at 11:25
  • And you are right about run time error.. " Process returned -1073741819 (0xC0000005) execution time : 3.086 s Press any key to continue. " – LearningSinceBigBang Jun 06 '16 at 11:31
  • http://stackoverflow.com/questions/5062471/how-can-i-compile-and-run-programs-using-graphics-h-in-codeblocks You've upgraded your compiler, so why not update your graphics library while you're at it? – Cody Gray - on strike Jun 06 '16 at 14:17
  • Sorry, I didn't quite get that. What do you mean by "why not update your graphics library" I am sure ready for that.. but what exactly you mean by that? – LearningSinceBigBang Jun 06 '16 at 21:35
  • The graphics.h header was obsolete over 20 years ago. It was only included with Turbo C, and only works in DOS. No one runs DOS anymore, and you've already upgraded your compiler to something newer than Turbo C. So it's time to upgrade your graphics library to something else. I'm not sure exactly what types of apps you're trying to write. That will determine which graphics library you use. Continuing to write full-screen DOS applications is rather a waste of time. It is not teaching you anything useful. – Cody Gray - on strike Jun 07 '16 at 03:39
  • As I said earlier, I am not at all into fullscreen stuff. I just need to write graphical programs. Ok, it depends on what type of applications I wanna write, so.. I will start with very basic. Please let me know any basic way to get started in graphics coding. Thank you. – LearningSinceBigBang Jun 07 '16 at 08:39

2 Answers2

1

[SOLVED]

Unfortunately, it was all about 'bad' library files. I think, many have downloaded same(with bug) files in internet. Now I have bug-free files shared in google drive. And also Code::Blocks 16.01 (latest version)

Here's link. Replace old files with these new ones.

I have explained those steps and few FAQs here on this topic with links and test codes.

0

use of DosBox for emulate MS-DOS in Windows7.

just i can help you with bellow link, its useful.

See : How use of DOSBox in Windows 7

  • I have used that. Infact, I had that compiler for a while. But I have upgraded to Code::Block. I just wanna graphic program in Code::Blocks. Cause, I have been using most of code blocks now. I am sorry, I thought you were gonna give some "plugin-sort" thing to include in code::Blocks – LearningSinceBigBang Jun 06 '16 at 11:48