1

I recently installed code::blocks 13.12 and also added the BGI graphics (I know its too old; needed it for a project). But a simple C++ graphics program like this -

#include <graphics.h>
#include <conio.h>

int main()
{
    int gd=DETECT, gm;
    initgraph(&gd, &gm, "C:\\TC\\BGI");

    circle(150,150,40);

    getch();
    closegraph();    
}

gives me a warning - "deprecated conversion from string constant to char* [-Wwrite-strings]"

Also the program does not execute; instead a pop-up window appears saying that "test.exe has stopped working"

I performed all the steps mentioned in videos online to add graphics in c::b (Eg. https://www.youtube.com/watch?v=YHmwwwPxpV8)

I noticed that my C: drive does not have a TC folder. Is that responsible? If yes, where do I get the required files?

One last thing - all programs that do not have graphics run smoothly.

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • Please check [this Stack Overflow question](https://stackoverflow.com/questions/1524356/c-deprecated-conversion-from-string-constant-to-char) to see if fixing your deprecated conversion error fixes any more of the problems with the code. – Maximillian Laumeister Aug 01 '15 at 06:34
  • Line no 7 where initgraph function is used warning is pointing that line is there any mistake in my code? – user5180054 Aug 01 '15 at 06:37

1 Answers1

0

char driver[]="C:\\TC\\BGI"; solution for "deprecated conversion from string constant to char* [-Wwrite-strings]". use it as
initgraph(&gd,&gm,driver);

Christopher Nolan
  • 930
  • 1
  • 11
  • 15