String Initialization without equal (=) Sign - My articles - Publisher - Information Technology
Saturday, 2016-12-03, 10:46 PM
ebooks Programming Computer Science
Welcome Guest | RSS
Site menu
Section categories
My articles [23]
Main » Articles » My articles

String Initialization without equal (=) Sign
#include<iostream>
#include<string>
using namespace std;
 
int main()
{
     string hi("What's your name?"),             //string hi="What's your name?",
              name,
              line(40,'-');
 
     cout << hi << endl;
     cout <<line << endl;
     cout << "My name is ";
     getline(cin,name);
     cout <<"hey " << name <<"!"
          <<"Your name has " <<name.length()<<" characters" << endl
 <<line << endl;
 
     return 0;
}
Category: My articles | Added by: Sumrat (2012-09-17)
Views: 26678 | Rating: 0.0/0
Total comments: 0
Name *:
Email *:
Code *:
Our poll
Rate my site
Total of answers: 152
Statistics

Total online: 1
Guests: 1
Users: 0
Login form