关于c++输入流的问题
#include <iostream>#include<sstream>
#include <string>
using namespace std;
int main()
{
int b;
string s = "45";
istringstream is(s);
is >> b;
string de{ "123A9.2" };
is.str(de);
int i;
char c;
double d;
is >> i >> c >> d;
cout << i << " " << c << " " << d << endl;
system("pause");
return 0;
}
最后字符串流怎么再回到流开头,我用is.seekg(0)不行啊,偏移量一直是-1 解决了,是当流读取到eof()后,后面的函数调用可能失效,用clear先清除一下就可以了
页:
[1]