Kamta Sahu
Kamta Sahu

Reputation: 170

Unable to use graphic programming in codeblock

#include<graphics.h>
#include<conio.h>
#include<iostream>
using namespace std;
int main()
{
   int gd = DETECT, gm;
   initgraph(&gd, &gm, "c:\\TC\\BGI" );
   cout<<"Please Enter to continue..."<<endl;
   getch();
   closegraph();
   return 0;
}

All other programmes are running fine on my Codeblock 13.12, but when I run a simple graphic programme compiler crashes giving pop up window that says:

"graphic.exe has stopped working window is checking solution".

It also giving a warning message on compilation:

warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]|

How to resolve it?It is due to turbo C.

Upvotes: 0

Views: 656

Answers (2)

Shawon
Shawon

Reputation: 21

For Graphics Programming In C You Need To Install Codeblocks-EP Version. Download From Here http://codeblocks.codecutter.org/setup.exe

Install And Then Go File>New>Project>Winbgim project>GO>>Add Console>>NEXT . Give Project Name,location path And Click Finish. Now Again File >New>Empty File

Write Your C graphics Code>> Build And Run.

This Codeblocks has pre installed built in graphics libraries. So You need not to add anything.

Upvotes: 0

πάντα ῥεῖ
πάντα ῥεῖ

Reputation: 1

It is due to turbo c.

Turbo c/c++ is ancient and didn't conform any standards. There are no such header files like conio.h or graphics.h for any modern c++ compilers.

Your codeblocks IDE most probably uses the GCC toolchain by default, which doesn't provide these headers.

You should lookup for more modern 3rd party libraries for handling graphics and raw keyboard input (e.g. something like SFML). The c++ standards have no notion about such stuff so far.

Upvotes: 3

Related Questions