adding char into a string
From: Jason (jason.carney1_at_btinternet.com)
Date: 12/30/03
- Next message: Jason: "Re: adding char into a string"
- Previous message: Guy Harrison: "Re: Accessing memory at 0xb800"
- Next in thread: Jason: "Re: adding char into a string"
- Reply: Jason: "Re: adding char into a string"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 30 Dec 2003 06:58:34 +0000 (UTC)
Hi,
can clarify for me how to add a single char into a string. At the moment I
do this:
str.insert((string::size_type) tileidx - 1, &ch);
and it corrupts str. If this is wrong perhaps somebody would be kind enough
to give me code for adding and removing a character from a string. I took
the following from josuttis book c++ standard template library, page 491,
for anyone that uses it:
s.insert((std::string::size_type)0, 1, ' ');
and changed it to the above, as it would not compile if the last argument is
not a pointer. I dont really want to insert single character strings into
my string if I can avoid it.
thanks for any help.
jason
- Next message: Jason: "Re: adding char into a string"
- Previous message: Guy Harrison: "Re: Accessing memory at 0xb800"
- Next in thread: Jason: "Re: adding char into a string"
- Reply: Jason: "Re: adding char into a string"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|