I miss my VB6. How do I join strings?
How do I join strings?
In VB I did this by simple "+"
text = "I have a" + "bad" + "hair" + "day today"
"I have a bad hare day today"
Is there a way to join strings with + here.
What library to use?
[232 byte] By [
Recoil] at [2007-11-11 10:01:57]

# 1 Re: I miss my VB6. How do I join strings?
The function strcat() make this , it takes two parameters and returns their concatenation .
also "+" operator is already overloaded in c++ string, u can use it directly :
string s ="Hello ";
string x ="World.";
s = s + x;
cout<<s; //result = Hello World.
Amahdy at 2007-11-11 20:59:36 >

# 2 Re: I miss my VB6. How do I join strings?
In C++, it's just as simple:
#include <string>
std::string text= "I";
text+=" have";
text+=" bad";
//etc.
Danny at 2007-11-11 21:00:32 >

# 4 Re: I miss my VB6. How do I join strings?
What is the error message you're getting? You need to warp the code inside a main() function of course but I thought it was obvious (at least to me...):
#include <string>
int main()
{
std::string text= "I";
text+=" have";
text+=" bad";
}
Danny at 2007-11-11 21:02:41 >

# 5 Re: I miss my VB6. How do I join strings?
Neither of the solutions seem to work.
U should say, u couldnt use neither of the solutions coz each one of them work <moreover they are the same> , and they are a demonstrate of one of the strings base in c++ .
To be able to use strings by a method similar to vb, u must use the header file "STRING" , and test both of them in the main function for example , but in c++ of corse u will use strings by a deeper method, more sensetive , and more efficient .
Amahdy at 2007-11-11 21:03:36 >
