I'm using the pdCurses library and am aiming to only really use strings in my C++ console game but the curses mvinstr() function or any insert function requires a non-const char * as a parameter.
- My solution at first to this problem was simply entering in
string.c_str(), but that returns aconst char *which apparently doesn't work with the function. - Next I put
(char *)string.c_str()but this only causes an unhandled exception. - Finally I just tried
char *test = string.c_str()but that's not compatible withconsteither.
What do I do to solve this?
K i just tried const_cast() and i still get an exception thrown and break.... I don't know why PDcurses only takes non-const char pointers.... =(
alright making a char* buffer didn't work when i used this code (time_s is the 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 a stop before mvinstr() and checked the buffer's contents which was "00 /0" EXACTLY WHAT I WANTED.
but i get an access violation point to "xutility"....