I am converting a std::string to a char[] in a c++ dll application to pass through to a C# application.
in my Header i have:
char m_Text[1000];
in my cpp function:
void createLogEntry(std::string logMessage)
{
logMessage = "testing testing";
// logMessage = "testing testing 12121221.121212 ,1 12. .121212. .2 2 21";
log_mutex.lock();
snprintf ( m_Text, 100, logMessage.c_str() );
log_mutex.unlock();
}
When I run the shorter string "testing testing", everything is fine. When I run with the other, commented out string, the application crashes. Why is this? And what can I do about it? I have tried using strcpy(m_Text, logMessage.c_str());
, I have tried a larger array, and i see the same thing.