0
    std::string tempGet;
    std::cout << "Enter flight START point: ";
    std::getline(in, tempGet);
    flight.start_point = tempGet;
    std::cout << "Enter flight FINAL point: ";
    std::getline(in, tempGet);
    flight.final_point = tempGet;
    std::cout << "Enter flight airplane name: ";
    std::getline(in, tempGet);
    flight.airplane = tempGet;

Hi!

This is part of my code.

flight is my class have three data member.

here my program ignore first getline and terminal be like this:

Enter flight START point: Enter flight FINAL point:

what is the problem ???

MrOutadi
  • 27
  • 2
  • 1
    You almost certainly have a line before your shown code that does `in >> somevar;` See [this](https://stackoverflow.com/q/21567291/2027196) if that's the case. – JohnFilleau Apr 21 '20 at 19:08

1 Answers1

1

If it ignores you when you in turn ignore it,

Before the first getline insert

#include <limits>

//...
in.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );

The problem is that the input buffer contains a new line character '\n' after input before the first call of getline.

Vlad from Moscow
  • 224,104
  • 15
  • 141
  • 268