This is in reference to the discussion in this topic here How to have a char pointer as an out parameter for C++ function
In the code below, where do I free the memory of pTemp? Is it not required? Would things would have changed in anyway if instead of array of chars there was array of integers?
void SetName( char **pszStr )
{
char* pTemp = new char[10];
strcpy(pTemp,"Mark");
*pszStr = pTemp;
}
int main(int argc, char* argv[])
{
char* pszName = NULL;
SetName( &pszName );
cout<<"Name - "<< pszName << endl;
delete [] pszName;
cin.get();
return 0;
}