🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #122

Re: convert *char to string

#122
From: Greg Comeau
Date: Fri, 14 Jan 2000 00:00
25 lines
1888 bytes
In article <387ed1c7@grissom> "Jarne Cook" <jarne@powerup.com.au> writes:
>Can anyone tell me how to convert a char* to a string or get access to each
>charater one by one.
>
>I am trying to get char* argv[1] ( the first argument) so that I can
>manipulate each character.  Can someone PLEEEZE tell me if there is a
>standard c++ call to do that.

If you mean the string "class" from the C++ Standard Library,
the Standard way is supposed to be to #include <string>,
and then just declare object with it.  It has a char * to string
constructor built in.  Do note though that by default the standard
will require that you use std::string and not just string, for instance:

#include <string>

string s("Hello, world");
// ...

- Greg
-- 
       Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418-3214
          Producers of Comeau C/C++ 4.2.42 -- NOTE 4.2.42 NOW AVAILABLE
    Email: comeau@comeaucomputing.com / Voice:718-945-0009 / Fax:718-441-2310
                *** WEB: http://www.comeaucomputing.com *** 
Technical Details
Message-ID: <85nfbh$rue$1@panix.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <387ed1c7@grissom>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,9c3f098f257151c0
X-Google-Attributes: gid109fba,public
X-Google-Thread: 10d4ba,9c3f098f257151c0
X-Google-Attributes: gid10d4ba,public
X-Google-Thread: 114592,9c3f098f257151c0
X-Google-Attributes: gid114592,public
From: comeau@panix.com (Greg Comeau)
Subject: Re: convert *char to string
Date: 2000/01/14
Message-ID: <85nfbh$rue$1@panix.com>
X-Deja-AN: 572596208
References: <387ed1c7@grissom>
X-Complaints-To: abuse@panix.com
X-Trace: news.panix.com 947863730 7224 166.84.0.226 (14 Jan 2000 15:28:50 GMT)
Organization: Comeau Computing; http://www.comeaucomputing.com
Reply-To: comeau@comeaucomputing.com
NNTP-Posting-Date: 14 Jan 2000 15:28:50 GMT
Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.lang.c++
X-Newsposter: trn 4.0-test55 (26 Feb 97)