How can one count in the first row and the second row? getline apparently starts reading from the \ n character.

#include <iostream> #include <string> using namespace std; int main() { int N; string s; cin >> N; getline(cin, s); cout << N << endl; cout << s << endl; system("pause"); } 

    1 answer 1

    After reading N flush the input buffer:

     cin.ignore(numeric_limits<streamsize>::max(), '\n');