S
Sims
Hi,
I have a function that looks something like ....
void Function( std::string &oldval )
{
int iSome_size = xxx; // get some size
char *tmp = NULL;
tmp = new char[iSome_size+1];
// get some text into the tmp
// and then copy the data to the std::string(...)
oldval = tmp;
delete [] tmp;
tmp = NULL;
}
// but the value passed to oldval is wrong, oldval gets allocated some
garbage.
// what am i missing?
Many thanks
Sims
I have a function that looks something like ....
void Function( std::string &oldval )
{
int iSome_size = xxx; // get some size
char *tmp = NULL;
tmp = new char[iSome_size+1];
// get some text into the tmp
// and then copy the data to the std::string(...)
oldval = tmp;
delete [] tmp;
tmp = NULL;
}
// but the value passed to oldval is wrong, oldval gets allocated some
garbage.
// what am i missing?
Many thanks
Sims