const char * is incompatible with parameter of type char *, initgraph()

535 Views Asked by At

I have been going through this: https://www.geeksforgeeks.org/draw-circle-c-graphics/ and for some reason it seems to not be working, I'm using vs 2019, I have the dependency's, no errors there, it seems its just the two quotes in initgraph(&gd, &gm, "");

error: E0167 argument of type "const char *" is incompatible with parameter of type "char *"

1

There are 1 best solutions below

13
Ted Lyngmo On BEST ANSWER

The third argument to initgraph should be a char* but in C++, "" is a const char[1].

void initgraph(int *graphdriver, int *graphmode, char *pathtodriver);

You can get around that problem by creating a char[1] and use that as an argument instead:

char pathtodriver[] = "";
initgraph(&gd, &gm, pathtodriver);