Define a string variable, assign a value and display it : string « String « C++






Define a string variable, assign a value and display it

  
 

#include <iostream>
#include <string>
using namespace std ;
using std::cout;       
using std::cin;

int main()
{
  string s = "www.java2s.com \n";
  cout <<s; 
  return 0;
}
/* 
www.java2s.com

 */
        
    
  








Related examples in the same category

1.string basics
2.copy constructor
3.Changing Case in Strings
4.A short string demonstration.A short string demonstration.
5.Extracting Words in Strings Delimited by Whitespace
6.Loop through the string array
7.Char Escapes