BW>void Enlarge(char *p)
BW>{
BW> char *x=new char[20];
BW> delete[] p;
BW> p=x;
BW>}
BW>void main()
BW>{
BW> char *sz=new char[10];
BW> Enlarge(sz);
BW>}
The sz _duplicate_ is pushed onto the stack and therefore the stack is
filled with the new address and not the sz variable in main.
BW>char *Enlarge(char *p)
BW>{
BW> char *x=new char[20];
BW> delete[] p;
BW> return x;
BW>}
BW>void main()
BW>{
BW> char *sz=new char[10];
BW> sz=Enlarge(sz);
BW>}
BW>so far seems to work, but am I even on the right track?
This works since the x is returned in the DX:AX registers (16 bit) or
EDX:EAX registers for 32 bit code and then it is assiged to the sz
variable. :)
* SLMR 2.1a * Back Up My Hard Drive? I Can't Find The Reverse Switch!
--- FMail 0.92
---------------
* Origin: The Programmer's Oasis on FIDONET! (1:348/203)
|