【发布时间】:2010-04-14 02:51:18
【问题描述】:
这是一个有趣的问题,我一直在试图弄清楚。我有以下程序:
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main(int argc, char *argv[])
{
string s("5");
istringstream stream(s);
double theValue;
stream >> theValue;
cout << theValue << endl;
cout << stream.fail();
}
输出是:
0
1
我不明白为什么会失败。有人可以告诉我我做错了什么吗?
谢谢,
螺旋形
编辑:
好的,很抱歉把它变成double post,但这看起来像是 Xcode 特有的问题。如果我在 g++ 中编译它,代码可以正常工作。有谁知道为什么在 Xcode 中会发生这种情况,以及我该如何解决它?
【问题讨论】:
标签: c++ string xcode parsing double