How to Concatonate strings?
I believe in string.h there is a function called strcat() look it up...it might be what you need.
Either that, or if you are using strstream, I think (but am not totally sure) you can do something like
string << "monkey" << "power";
-=Lohrno
Either that, or if you are using strstream, I think (but am not totally sure) you can do something like
string << "monkey" << "power";
-=Lohrno
What language?
The world holds two classes of men -- intelligent men without religion, and religious men without intelligence. - Abu''l-Ala-Al-Ma''arri (973-1057; Syrian poet)
The world holds two classes of men -- intelligent men without religion, and religious men without intelligence. - Abu''l-Ala-Al-Ma''arri (973-1057; Syrian poet)
thanks!
In C++, and how would i concatonate without using count, sopse i have a 3d text display in my program.
like this:
string3 = string1+string2;
In C++, and how would i concatonate without using count, sopse i have a 3d text display in my program.
like this:
string3 = string1+string2;
#include <string>using namespace std;string str1 = "monkey";string str2 = "power";string str3 = str1 + str2; // str3 == "monkeypower"str2 = "monkey" + str2; // str2 == "monkeypower" toostr1 += "power"; // str1 == "monkeypower" too
Or
#include <sstream>#include <string>using namespace std;stringstream ss;ss << "monkey" << "power";string str = ss.str();
Do not use strstream.
Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
You can do it two ways without using cout (I think thats what you meant...)
strcat() (I forget the exact parameters...I think it''s something like: string3 = strcat(string1, string2) )
or you can do sprintf(string3,"%s%s",string1, string2);
(sprintf works like printf to a string)
(yes I think I meant stringstream, fruny knows what he''s talking about )
-=Lohrno
strcat() (I forget the exact parameters...I think it''s something like: string3 = strcat(string1, string2) )
or you can do sprintf(string3,"%s%s",string1, string2);
(sprintf works like printf to a string)
(yes I think I meant stringstream, fruny knows what he''s talking about )
-=Lohrno
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement