Difference between revisions of "CPP/Strings/Concatenate"
From ProgrammingExamples
< CPP
FirstPerson (Talk | contribs) (→Concatenate.cpp) |
Daviddoria (Talk | contribs) |
||
| Line 3: | Line 3: | ||
#include <iostream> | #include <iostream> | ||
#include <string> | #include <string> | ||
| − | |||
| − | |||
| − | |||
int main() | int main() | ||
{ | { | ||
| − | string | + | std::string string1 = "Hello"; |
| − | string | + | string string2 = "World"; |
| − | + | ||
| − | // | + | // Concatenate strings together using the operator + |
| − | string | + | string full = string1 + " " + string2; |
| − | cout << | + | std::cout << full << std::endl; |
return 0; | return 0; | ||
} | } | ||
</source> | </source> | ||
Latest revision as of 09: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; }