home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / std / cplus / 2016 < prev    next >
Encoding:
Text File  |  1993-01-09  |  1021 b   |  28 lines

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