So I\'m trying to copy one char array to another (without using thestring classe
ID: 3610159 • Letter: S
Question
So I'm trying to copy one char array to another (without using thestring classes), but I'm running into a problem.When I re-initialize dest, I get a large amount of junk; how wouldI go about deleting the stuff after the relevant data?
Function:
void String::Copy(const char* src,char*& dest)
{
int size = GetLength(src); //GetLength(s) isessentially strlen(s)
delete[] dest;
dest = new char[size];
for(int i = 0; i < size; i++)
dest[i] = src[i];
}
For example, using asdf as src, I get this:
src 0x0014f6dc "asdf" constchar *
dest 0x007554d0"asdfýýýý««««««««" char * &
Will rate lifesaver if your solution solves my problem.
Using MSVS 2008.