我正在尝试使用标头文件sstream.h
以下是我的代码段
#include <iostream>
#include <string>
#include <sstream>
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;
}
但我收到了以下错误
unable to open include file sstream.h
有没有人知道我做错了什么?
答案 0 :(得分:3)
有很多问题,请尝试以下方法:
#include <iostream>
#include <string>
#include <sstream>
#include <cstdio>
int main()
{
std::string st = "23 53";
int result;
std::stringstream(st) >> result;
getchar();
return 0;
}
一些:
getchar
代替getch
<cstdio>
getchar
string
stringstream
和std::
sstream
,而不是sstream.h