confusion about the function "getline"

I am trying a sample piece of code in the Documentation as following:
// stringstreams
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main ()
{
string mystr;
float price=0;
int quantity=0;

cout << "Enter price: ";
getline (cin,mystr);
stringstream(mystr) >> price;
cout << "Enter quantity: ";
getline (cin,mystr);
stringstream(mystr) >> quantity;
cout << "Total price: " << price*quantity << endl;
return 0;
}

the expected result is

Enter price: 22.25
Enter quantity: 7
Total price: 155.75

When I compiled it with VS2005 I actually got the exact result.
But when I tried it with VC6.0,the situation changed as following:

Enter price:22.25
(when I typed "Enter" key after 22.25,here come a blank line)
Enter quantity: 7
Total price: 0

I was really confused, anybody can tell me WHY?Thanx.
The VC++ 6.0 implementation is terrible. If you're getting wrong results from it, don't worry. It's probably the implementation that's wrong.
Topic archived. No new replies allowed.