Search code examples
c++codeblocksbgi

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.


Solution

  • 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.