So, I have a program that uses the graphics mode [graphics.h
] library...
and I want to initialize the graph, So I would do this so naturally do this :
initgraph(graphics_driver,graphics_mode,"") ;
When I compile the above, it gives the error "ISO C++ forbids converting a string constant to char*"
I know one workaround for this :
char c_array[] = "" ;
initgraph(graphics_driver,graphics_mode,c_array) ;
The above compiles just fine...
This is ok with functions like initgraph()
.. because I will only be calling it once. But, I would like to use the outtextxy()
function like this (Because I call it multiple times in my program) :
outtextxy(0,0,"Test") ;
Because declaring an array for all the different outtextxy()
functions will just be a waste of space.
So, is there any way to use the above without arrays or any extra variables?
P.S: I am using codeblocks after installing the graphics.h
library and configuring all the linker options. etc...
If you are absolutely sure that outtextxy()
will not modify the string passed to it you could write you own wrapper function like:
void my_outtextxy(int x, int y, const char* text) {
outtextxy(x, y, const_cast<char*>(text));
}