Difference between revisions of "CPP/Strings/Concatenate"
From ProgrammingExamples
< CPP
Daviddoria (Talk | contribs) (Created page with '==Concatenate.cpp== <source lang="cpp"> #include <iostream> #include <string> #include <sstream> using namespace std; int main() { string test; test = "hello"; int scan =…') |
Daviddoria (Talk | contribs) |
||
(One intermediate revision by one other user not shown) | |||
Line 3: | Line 3: | ||
#include <iostream> | #include <iostream> | ||
#include <string> | #include <string> | ||
− | |||
− | |||
− | |||
int main() | int main() | ||
{ | { | ||
− | string | + | std::string string1 = "Hello"; |
− | + | string string2 = "World"; | |
− | + | ||
− | string | + | // Concatenate strings together using the operator + |
+ | string full = string1 + " " + string2; | ||
− | + | std::cout << full << std::endl; | |
− | + | ||
− | + | ||
− | + | ||
return 0; | return 0; | ||
} | } | ||
</source> | </source> |
Latest revision as of 10:31, 2 February 2011
Concatenate.cpp
#include <iostream> #include <string> int main() { std::string string1 = "Hello"; string string2 = "World"; // Concatenate strings together using the operator + string full = string1 + " " + string2; std::cout << full << std::endl; return 0; }