I use the pdCurses library and try to use only strings in my console game in C ++, but the curses mvinstr() function or any insert function requires no char * constant as a parameter.
- My solution at first for this problem was to simply put in
string.c_str() , but that returns a const char * , which apparently doesn't work with this function. - Then I put
(char *)string.c_str() , but this only raises an unhandled exception. - Finally, I just tried
char *test = string.c_str() but is not compatible with const .
What should I do to solve this problem?
K I just tried const_cast () and I still get the exception and the break .... I don't know why PDcurses accepts only non-const char pointers .... = (
in the order in which the buffer was created, char * did not work when I used this code (time_s is a sting):
size_t length; char buffer[12]; length=time_s.copy(buffer,5,0); buffer[length]='\0'; mvinstr(time_loc_y, time_loc_x, buffer);
I even put an end to mvinstr () and checked the contents of the buffer, which was "00/0", EXACTLY WHAT I WANT.
but I get a "xutility" access violation point ....
source share