#include <iostream>
#include <string>
#include <set>
using namespace std;
int main()
{
int N; //number of bank accounts
cin >> N;
int n = 0;
multiset<string> bank_accounts;
string account;
while (n < N)
{
getline(cin, account);
bank_accounts.insert(account);
n++;
}
}
When I input N = 1
, the loop doesn't take any input and the program exits but when instead of getline(cin, account)
I use cin >> account
it works . I have inputs which have spaces so I need to use getline()
only but I can't understand this strange behaviour .