I want to take input from the user until he presses enter key. I have used the following approach, but in vain, as the loop won't terminate. Please help.
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
vector<int> array;
cout<<"Please enter the elements of the array"<<endl;
while(cin>>n) {
array.push_back(n);
}
for(auto i: array){
cout<<i<<" ";
}
cout<<endl;
return 0;
}