TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: All
from: Jasen Betts
date: 2003-01-01 14:16:14
subject: complete idiot or what?

Hi All.

Complete idiot's guide to C++ says the following.

// Listing 23_5

#include 
#include 

int main()
{
   char* name;
   name = new char;

   strcpy(name,"PAUL");
   cout << name;
   delete name;
   return 0;
}

is that combination of new and strcpy "right"?
it looks highly suspicious to me.

Something like "name = new char[5]"  seems better to me, would that be
correct?

-=> Bye <=-

---
* Origin: If at first you don't succeed, the hell with it. (3:640/1042)
SEEN-BY: 633/267 270
@PATH: 640/1042 531 954 774/605 123/500 106/1 379/1 633/267

SOURCE: echomail via fidonet.ozzmosis.com

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