|
-
March 21st, 2003, 07:40 AM
#1
Memory problem
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()?....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|