Questions tagged «sstream»

4
stringstream到底做什么?
自昨天以来,我一直在尝试学习C ++,并且正在使用以下文档:http : //www.cplusplus.com/files/tutorial.pdf(第32页)。我在文档中找到了代码,然后运行了它。我尝试输入5.5卢比的价格,输入整数作为数量,输出为0。我尝试输入5.5和6,输出正确。 // 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 …
107 c++  sstream 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.