I'm new here and just started my first class program. It's an input/output assignment and I'm using getline to store the string values since I anticipate whitespace being used. The problem is that in the console, the code doesn't allow me to input anything for my favorite city, leaving it blank.

#include <iostream>
#include <string>

using namespace std;

int main()
{
int userAgeMnths;
float userHeight;
char one, two, three;
string userName, gNumber, favCity;

    cout << "Enter your name: ";
    getline(cin,userName);
    cout << endl << "Enter your G-Number: ";
    getline(cin,gNumber);
    cout << endl << "Enter your height in inches: ";
    cin >> userHeight;
    cout << endl << "Enter your age in months: ";
    cin >> userAgeMnths;
    cout << endl << "Enter three characters: ";
    cin >> one >> two >> three;
    cout << endl << "Enter your favorite city: ";
    getline(cin,favCity);

    cout << endl << endl << userName << ", " << gNumber << endl << endl;
    cout << three << two << one << endl << endl;
    cout << favCity.length() << endl << endl;







    return 0;
}

Heres my output:

Enter your name: Wireboy guy

Enter your G-Number: g111111111111111

Enter your height in inches: 99999

Enter your age in months: 99

Enter three characters: abc

Enter your favorite city:

Wireboy guy, g111111111111111

cba

0

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.