Re: How to convert from string to char*?
- From: "John Carson" <jcarson_n_o_sp_am_@xxxxxxxxxxxxxxx>
- Date: Wed, 28 Feb 2007 17:05:39 +1100
"Lorry Astra" <LorryAstra@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:654CE450-394B-4E24-967D-E8CDE85FBEF2@xxxxxxxxxxxxx
hi,
i have two questions:
1. How to convert from string to char*? I use c_str() of string, but
it returns "const char*" instead of char*;
One way is to create a char array and copy from c_str() to it.
2. When i use copy() function of string, i always get some unknown
characters from the first parameter (char*) after using copy()
function.(these unknow character is like "<<" or ">>", but my string
doesn't include these characters.)
Using copy won't nul-terminate the string, so you will get junk characters
after the characters you copy. If you use this approach, then you need to
nul-terminate manually. If this doesn't solve the problem, then post
(compileable) code showing what you are doing.
--
John Carson
.
- Prev by Date: RE: Side-by-Side hell with Visual Studio 2005 SP1
- Next by Date: Re: How can I run '.sql' script from vc++
- Previous by thread: RE: Side-by-Side hell with Visual Studio 2005 SP1
- Next by thread: Re: How to convert from string to char*?
- Index(es):
Relevant Pages
|