charPointer getCopy(const charPointer& s) //typedef char* charpointer
{
/*
returns a new cstring that is a copy of the cstring s.
That is a new cstring with as big memory as the size of
the cstring s is created and then all the characters of
s including the null char are copied to it.
*/
int len=cstrlen(s);
char *A=new char[len];
for(int i=0;i<len;i++)
{
A[i]=s[i];
}
A[len]='\0';
return A;
}
- Как мне вернуть ту же строку? Я новичок в C ++, пожалуйста, помогите !!
- Также, если я запускаю в Visual C ++, это дает мне ошибку уничтожения кучи.