electroRF
Member
Hi,
I wrote the following C++ constructor, and I get an error - BUFFER too small on strcpy_s
m_name is a private data member of type char* .
You have an idea why I get this error?
I wrote the following C++ constructor, and I get an error - BUFFER too small on strcpy_s
Code:
Trace::Trace(const char *str)
{
if (str)
{
int len = strlen(str);
this->m_name = new char[len+1]; // asking for 'len+1' memory elements of char
strcpy_s(m_name, len, str); // **** I get here an error "BUFFER TOO SMALL" ****
cout << "start of " << m_name << endl;
}
else
{
m_name = new char[1];
m_name[0] = '\0';
}
}
m_name is a private data member of type char* .
You have an idea why I get this error?