【发布时间】:2014-03-31 20:13:21
【问题描述】:
我正在尝试使用stoi 将字符串转换为整数,但是它说它没有被声明。我有标准库和<string>,但它仍然显示[Error] 'stoi' was not declared in this scope
代码如下:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
int main()
{
string end, init;
cout << "Introduction" << endl;
cout << "Start time (xx:yy)" << endl;
cin >> init;
string hours0 = init.substr(0,2);
int hours = stoi(hours0);
cout << hours << endl;
system("pause");
return 0;
}
请告诉我为什么它不起作用,或者给我第二个选择。
【问题讨论】:
-
他们在这里回答这个问题:askubuntu.com/questions/731748/…