У меня возникла проблема, когда мой цикл for-loop пропускает функцию getline. Если я заменил его на std :: cin, тогда он работает, поэтому я думаю, что это связано с тем, что я ввел в getline.For-Loop Skipping getline C++
Вот мой код.
void setLocations(int amount) {
locations = new std::string[amount];
locations[0] = startingLocation;
// starts at 1 because we want to skip first index. The amount is set at 2 by default, so the loop should iterate at least once.
for (int x = 1; x < amount; x++)
std::getline(std::cin, locations[x]);
}
http://stackoverflow.com/questions/6819082/stdgetline-on-stdcin – HelloWorld
http://stackoverflow.com/questions/257091/how- do-i-flush-the-cin-buffer –