Output a string via cout - C++ STL

C++ examples for STL:string

Description

Output a string via cout

Demo Code

#include <iostream>
#include <string>
using namespace std;
int main()//from w  ww. ja va2s  .  c o  m
{
   // using the string literal passed as an argument.
   string str1("Alpha");
   string str2("Beta");
   string str3("Gamma");
   string str4;
   // Output a string via cout.
   cout << "Here are the original strings:\n";
   cout << "  str1: " << str1 << endl;
   cout << "  str2: " << str2 << endl;
   cout << "  str3: " << str3 << "\n\n";
   return 0;
}

Result


Related Tutorials