-2
我想使用stod將矢量字符串轉換爲矢量double。將矢量<string>轉換爲矢量<double> C++錯誤
到目前爲止,我有:
vector<string> i = {"2.2", "2313.1"};
vector<double> rebuild;
for (int i=0; i<=v.size(); i++) {
rebuild.push_back(stod(v[i])); ///converts vector<string> to vector<double>
}
,但我得到的錯誤 「與類型爲std未捕獲的異常:: invalid_argument終止:STOD:無轉換」
我在做什麼錯?
:/我怎麼能錯過呢?謝謝。 –
或者如果你使用C++ 11,另一個選項是for(auto d:v)' – sbooth