I'm hoping that this will be a pretty basic problem that is maybe due to my lack of understanding a lot of the C++ Win32 API utlities.
Anyway, I'm having some trouble with the sprintf()
function. I had no problem using it with a string like this:
//memory is a void pointer that maps a file to shared memory
sprintf((char *)memory, "Shared memory message"); //Write to shared memory
But when I try to use a string
variable it doesn't work....
sprintf((char *)memory, str_var); //Write to shared memory
I get an error that says: no suitable conversion function from "std::string" to "const char *" exists
. I am not even able to fix this by type casting, like I did with memory
.
This seems pretty inconsistent. What am I doing wrong, and how do I give it a value that it will accept?