Cin How to enter a space (getline)

Source: Internet
Author: User
Tags first string

Tag: cin getline

    string strname[10];    for (int i=0;i<3;i++)      {        cin>>strName[i];     }    for (int i=0;i<3;i++)     {         cout<<strname[i]<<endl;    }    // Input  feng yu zai tu , return to print out  feng yu zai tu     In fact, this is just the first string, but because of the space, we can not enter the     //to lead to the question of how to enter the space, especially the names such as   I want to enter      //  Cloud   nie   wind   male   PA     //But because the space cannot be entered the problem            Solution:    cout<< "Please enter your name  : "<<endl;    string name;    int age;     getline (CIN,Name);    cout<< "PLEASE&NBSP;ENTER&NBSP;YOUR&NBSP;AGE&NBSP;:" <<endl;     cin>>age;    cout<< "your name is " << name<<endl;    cout<< "your age is " <<age<<endl;

In fact, how do I decide to receive a space and then return

Cin How to enter a space (getline)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.