user5180054
user5180054

Reputation: 11

"Deprecated conversion from string constant to char*" when using BGI?

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.

Upvotes: 1

Views: 1330

Answers (1)

Christopher Nolan
Christopher Nolan

Reputation: 1107

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

Upvotes: 0

Related Questions