Board index » cppbuilder » Re: string

Re: string


2003-07-24 12:15:02 PM
cppbuilder26
yupz, i tried that one but it doesn't work. it only works for ansistrings.
is there other way of doing it?
i tried ostreamstring, but i don't know how to clear it after using it. i used (ostreamstringvarname).clear() but it doesn't clear the contents.
" Bruce Salzman" < XXXX@XXXXX.COM >wrote:
Quote
string s = "the first string is " + a + " and the second one is" + b;

One line...is that what you meant by shorter?



 
 

Re:Re: string

i'm sorry, i mean ostringstream.
"jaycee" < XXXX@XXXXX.COM >wrote:
Quote

yupz, i tried that one but it doesn't work. it only works for ansistrings.
is there other way of doing it?
i tried ostreamstring, but i don't know how to clear it after using it. i used (ostreamstringvarname).clear() but it doesn't clear the contents.

" Bruce Salzman" < XXXX@XXXXX.COM >wrote:
>string s = "the first string is " + a + " and the second one is" + b;
>
>One line...is that what you meant by shorter?
>
>
>

 

Re:Re: string

"jaycee" < XXXX@XXXXX.COM >writes:
[Rearranged quotes]
Quote
" Bruce Salzman" < XXXX@XXXXX.COM >wrote:
>string s = "the first string is " + a + " and the second one is" + b;
>
>One line...is that what you meant by shorter?

yupz, i tried that one but it doesn't work.
Please remove the term "it doesn't work" from your active language posted to
newsgroups; it doesn't work :-)
Always say *what* doesn't work
- compiler error (quote the error message)
- linker error (quote the error message)
- unexpected behavior (what did you expect? what happened instead?)
- access violation (where in the code?)
- etc.
Quote
it only works for ansistrings.
I fail to see the difference between std::string and AnsiString in the
expression.
The above expression attempts to apply binary + to an array of char const and
a pointer to char. There is no operator+ for these two operand types,
independently of the type of s.
The easiest solution is to construct a std::string from the first operand;
std::string s(std::string("the first string is ")
+ a
+ " and the second one is"
+ b);
 

{smallsort}

Re:Re: string

Hello all
I have a AnsiString variable
String = "Rain*Humidity*Water*Dust"
This values should be stored in 4 different variables.
s1 = Rain
s2 = Humidity
s3=Water
s4=Dust
Can anybody provide the solution for this
Thank
SA
 

Re:Re: string

"bar" < XXXX@XXXXX.COM >wrote:
Quote
I have a AnsiString variable
String = "Rain*Humidity*Water*Dust"

This values should be stored in 4 different variables.
Either loop through the string's characters and look out for '*'
to get the individual strings or use a TStringList and split
the String into its parts with ExtractStrings().
 

Re:Re: string

Quote
Can anybody provide the solution for this
Look here:
tinyurl.com/2tecjc
(Search for Gambit's and Hans's code, even mine)
--
Best Regards,
Vladimir Stefanovic