What is the significance of memory in the following code:
consider function
// code begin
char* ReturnDup(const char* pChOrg)
{
char* pChDup;
pChDup = new char[strlen(pChOrg)+1];
strcpy(pChDup,pChOrg);
return pChDup;
}
// code over
suppose main program uses this function, like
// code begin
...
...
char* pChFun;
pChFun = ReturnDup("Life is wonderful");
cout << pChFun << endl;
...
...
...
// code over
what ever memory we have allocated is in function ReturnDup, doesnt it remain local in the function ReturnDup?
how can we use the return value in main()?....