Hi, all.
I have one question: I am writing my-string class now according to the assignment. And like other String class assignment, we have to overload the operator, do the difference type constructor, etc. Well, i almost finish my assignment. But there have one problem with my code.
I am not allowed to use strcpy() and strcat() fuction in my code cause it will cause NULL Terminator. So i changed them to strcpy_s() and strcat_s() which i still not allowed to.
So now i am became crazy, here is one part of my code and i was thinking maybe someone could help me figure out that.(is that use loop will avoid NULL Terminator???)
String& String::operator+=(char* other)
{
char* temp;
m_length=strlen(m_buffer)+strlen(other)+1;//m_length and m_buffer in my String class private elements
temp=new char[m_length];
//strcpy_s(temp,m_length,m_buffer);//this one i am not allowed to use now.
//strcat_s(temp,m_length,other);//this one i am also not allowed to use now.
char *t=m_buffer;
m_buffer=temp;
delete []t;
return *this; //my code
}
thanks la!!