www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/12/24/15:27:02

From: "Tom" <thomasbd AT erols DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Converting a string to a char *
Date: Fri, 24 Dec 1999 14:58:35 -0500
Lines: 22
Message-ID: <840i65$auc$1@bob.news.rcn.net>
X-Trace: 6Iq0vLVhaXfP1vXFtgN349ErQ+o5Pwwl10nnmDzxklO8vhIXGjdI8w==
X-Complaints-To: abuse AT rcn DOT com
NNTP-Posting-Date: 24 Dec 1999 19:39:49 GMT
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MSMail-Priority: Normal
X-Priority: 3
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I am trying to change a string to a char *.  I am using the function c_str()
but I am having problems with it.

How would I go about assigning the new char * value to a char *?  For
example, this is what I
tried to do and it didn't work.  It gave me a (null) result when it should
have said "test".  Thanks.

______________________________

int main()
{
string s = "test";
char *b;
*b = *s.c_str();
cout << b;
return 0;
}




- Raw text -


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