Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Input problems/ Spacing

Name: AnonRanger 2012-09-24 19:08

I'm using Visual c++ 2010, and I'm learning about having the user input values for the variable when using String data type. So I used this:
------------------------------------------------------
#include <iostream>
#include <string>
using namespace std;

int main()
{
    string name, college, major;
    cout << "What is your first name? ";
    cin >> name;
    cout << "What college do you go to? ";
    cin >> college;
    cout << "What is your major? ";
    cin >> major;
    cout << "Processing..." <<endl;
    cout << "Your name is " << name << endl;
    cout << "You attend " << college << endl;
    cout << "You are a/an " << major << " major" << endl;
    system("pause");
}
---------------------------------------------

But when I run it, if I try and input a name with a space, such as Hideo Kojima, it will ask the next two prompts on the same line. If I just put Hideo, or even Hideo_Kojima, it wont do that. Is it possible to input the first and last name with a space in between without this happening?

Name: Anonymous 2012-09-24 19:15

Back to Stack Overflow, ``please"!

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List