无法在 C++ 中打开包含文件 sstream.h

unable to open include file sstream.h in c++

本文关键字:包含 文件 sstream C++      更新时间:2023-10-16

我正在尝试使用头文件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

有谁知道我做错了什么?

有很多问题,请尝试以下操作:

#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
  • 通过std:: stringstringstream资格
  • sstream,而不是sstream.h
相关文章: