#getline not waiting for user input

4 messages · Page 1 of 1 (latest)

low solsticeBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

#

@hazy stump

Screenshots!

Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!

hazy stump
#
#include <iostream>
#include "Horse.h"
using namespace std;

int main()
{
    int horsesCount = 0;
    while (horsesCount < 1) {
        cout << "Please enter the number of horses. (at least 1)\n";
        cin >> horsesCount;
    }
    Horse* horses = nullptr;
    for (int i = 0; i < horsesCount; i++) {
        string name, rider;
        cout << "Please enter horse #" << i+1 << "'s name:\n";
        getline(cin, name);
        cout << "Please enter rider #" << i + 1 << "'s name:\n";
        getline(cin, rider);
        horses[i] = *new Horse(name, rider);
    }
}
#

here is the console