TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: BRIAN WOOD
from: ROGER SCUDDER
date: 1998-02-01 05:52:00
subject: returning char. after delete[]

Hello Brian.
29 Jan 98 23:14, Brian Wood wrote to All:
BW>    cout << FuncToGetSomeString(20) << endl;
BW> }
BW> char *FuncToGetSomeString( int len )
BW> {
BW>    char *psz = new char[len];
BW>    strcpy( psz, "Should I Do This???" );
BW>    delete[] psz;
BW>    return psz;
BW> }
 No.  It may work for you, but it's not guaranteed to and is
 very poor programming style.  De-allocate the array after you
 are finished using it.
 -Roger
... A big enough hammer can usually fix anything.
--- Msged 4.20 beta 3
(1:273/404@fidonet)
---------------
* Origin: Hodge-Podge Support BBS, Upper Darby, Pennsylvania, USA

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™.