www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/04/18:59:04

From: "Tom" <thomasbd AT erols DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Convert from basic_string to char *...
Date: Mon, 4 Oct 1999 17:50:17 -0400
Lines: 52
Message-ID: <7tb715$brq$1@autumn.news.rcn.net>
References: <7tb6c9$770$1 AT autumn DOT news DOT rcn DOT net>
X-Trace: CfVNtThY5HWEWTROzHNGo5oQb7SuybT9BmmJKXcK/Q9to4i0AmQ5HQ==
X-Complaints-To: abuse AT rcn DOT com
NNTP-Posting-Date: 4 Oct 1999 21:43:01 GMT
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MSMail-Priority: Normal
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

The above program didn't work, but I still want to know how to do the bottom
one.  Thanks.  And also add the following to the top:

#include <fstream>
#include <string>

Tom <thomasbd AT erols DOT com> wrote in message
news:7tb6c9$770$1 AT autumn DOT news DOT rcn DOT net...
> Is it possible to convert a string that was obtained using getline into a
> char *?  I know how to convert regular strings to char * but when I try a
> line obtained from getline it says it can't convert basic_string to char
*.
>
> _________________________
> int main()
> {
> char *test1 = "hello";
> string test2= "hi";
>
> cout << test1 << endl;
> cout << test2 << endl;
>
> test1 = test2;
>
> cout << test1;
> return 0;
> }
> _______________________________
>
> The above program works.  I want to do the following without errors.
>
> int main()
> {
> string s;
> char *b[500];
> int n = 0;
>
> ifstream inputfile("text.txt");
> while ( getline( inputfile, s) )
> {
> b[++n] = s;
> cout << b[n] << endl;
> }
> return 0;
> }
> ___________________
>
> Is this possbile?  Thanks.
>
>


- Raw text -


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