我正在尝试使用stoi将字符串转换为整数,但是它表示它没有声明.我有标准库和包含,但它仍然说"[错误]'stoi'未在此范围内声明"
代码如下:
#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;
}
Run Code Online (Sandbox Code Playgroud)
请告诉我它为什么不起作用,或者给我第二个选择.