I am using priority queue from the C++ STL library and I want to keep pushing elements into the queue till the user presses Enter.
I've tried using getchar() to get the input of the elements but it gets saved as a series of 1's in the queue.
priority_queue<int> v1;
priority_queue<int, vector<int>, greater<int> > v2;
cout<<"Enter the elements of the queue. Press enter to stop.\n";
while(a = getchar()!= '\n')
{
v1.push(a);
v2.push(a);
}
while(!v1.empty())
{
cout<<v1.top()<<" ";
v1.pop();
}
I expected the output to be the min and max heap of the elements entered, but all it gives me is a series of 1's