home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: initialized 'global' (extern) char arrays
- Message-ID: <1993Jan9.172228.13126@taumet.com>
- Organization: TauMetric Corporation
- References: <1993Jan7.032458.21941@netcom.com> <9300812.4657@mulga.cs.mu.OZ.AU> <1993Jan8.135547.26553@litwin.com>
- Date: Sat, 9 Jan 1993 17:22:28 GMT
- Lines: 17
-
- mbb@litwin.com (Mark Beyleveld) writes:
-
- >char * x = strdup("abcde");
- >char * y = new char[6];
- >(void) strcpy(y, "abcde");
-
- >Further down the road, I want to dispose of the data (which is legal,
- >since both are dynamically allocated). Do I use free or delete?
-
- Is it not a good idea to use a C library version of strdup (which is
- not part of the C Standard anyway) in a C++ program, for exactly this
- reason. If you need strdup, you would be better off writing your own
- as a C++ function, possibly giving it another name to reduce confusion
- for the readers of the program.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
-