why is cin.get() discarding newline?

In the following code, why isn't pa->height equal to the null character, since after I enter the name, newline is left in the input queue? When I run it, I can still enter a value for the height.

almond* pa = new almond;
cout << "Enter name of almond\n";
cin.get((*pa).name, 20);
cout << "Enter height of almond in cm\n";
cin >> pa->height;
cout << "Enter price of almond\n";
cin >> pa->price;

That's because cin >> pa->height; will first discard any initial whitespace characters that it finds before it starts reading from the first non-whitespace character.
Topic archived. No new replies allowed.