TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: BRIAN WOOD
date: 1998-02-02 10:19:00
subject: more questions about new

I'm having trouble doing something like this...
void Enlarge(char *p)
{
   char *x=new char[20];
   delete[] p;
   p=x;
}
void main()
{
   char *sz=new char[10];
   Enlarge(sz);
}
Using the debugger, it looks like p does get the address of x, but after
the function, sz is the same address, an empty string?  Trying to do
it different, like this...
char *Enlarge(char *p)
{
   char *x=new char[20];
   delete[] p;
   return x;
}
void main()
{
   char *sz=new char[10];
   sz=Enlarge(sz);
}
so far seems to work, but am I even on the right track?
L8r,
bw
--- Blue Wave/DOS v2.20
---------------
* Origin: River Canyon Rd. BBS Chattanooga, Tn (1:362/627)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.