Difference between revisions of "CPP/Strings/Concatenate"

From ProgrammingExamples
< CPP
Jump to: navigation, search
(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 =…')
 
(Concatenate.cpp)
Line 9: Line 9:
 
int main()
 
int main()
 
{
 
{
   string test;
+
   string firstName = "jello";
  test = "hello";
+
   string middleName = "K.";
   int scan = 34;
+
   string lastName = "mello";
   string test2;
+
  
   stringstream out;
+
   //concat strings together using the operator +
   out << scan;
+
   string fullName = firstName + " " + middleName + " " + lastName;
  test2 = out.str();
+
 
   cout << test << test2 << endl;
+
   cout << fullName << endl;
 
   return 0;
 
   return 0;
 
}
 
}
  
 
</source>
 
</source>

Revision as of 00:32, 29 June 2010

Concatenate.cpp

#include <iostream>
#include <string>
#include <sstream>
 
using namespace std;
 
int main()
{
  string firstName = "jello";
  string middleName = "K.";
  string lastName = "mello";
 
  //concat strings together using the operator +
  string fullName = firstName + " " + middleName + " " + lastName;
 
  cout << fullName << endl;
  return 0;
}