www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/12/24/21:19:33

From: bowman AT montana DOT com (bowman)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Converting a string to a char *
References: <840i65$auc$1 AT bob DOT news DOT rcn DOT net> <MPG DOT 12ce1d301f91f34e98b78e AT news DOT freeserve DOT net>
User-Agent: slrn/0.9.5.7 (UNIX)
Lines: 14
Message-ID: <auV84.1816$GS5.3306@newsfeed.slurp.net>
Date: Sat, 25 Dec 1999 01:55:18 GMT
NNTP-Posting-Host: 208.4.224.19
X-Trace: newsfeed.slurp.net 946086918 208.4.224.19 (Fri, 24 Dec 1999 19:55:18 CDT)
NNTP-Posting-Date: Fri, 24 Dec 1999 19:55:18 CDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Andrew R. Gillett <arganoid AT fatal-design DOT com> wrote:

>> *b = *s.c_str();
>
>Change this to:
>
>strcpy (b, s.c_str());

b is a pointer to char. s.c_str() returns a pointer to char. So,
b = s.c_str() would work.

Doing a strcpy of some arbitrarily long string to a pointer that was
never initialized will dump core and die, if you are lucky.  

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019