注册 登录
编程论坛 C++教室

新手求教sstream

豆豆芽 发布于 2017-03-17 10:29, 1777 次点击
只有本站会员才能查看附件,请 登录

为什么会多出一行空行 运行结果不对
只有本站会员才能查看附件,请 登录

#if 1
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

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

  cout << "Enter quantity: ";
  getline (cin,mystr);
  stringstream(mystr) >> quantity;
  cout << "Enter price: ";
  getline (cin,mystr);
  stringstream(mystr) >> price;

  cout << "Total price: " << quantity*price << endl;
  return 0;
}
#endif
1 回复
#2
luoj752017-03-21 00:03
只有本站会员才能查看附件,请 登录

可以的呀
1