小编use*_*512的帖子

功能stoi没有声明

我正在尝试使用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)

请告诉我它为什么不起作用,或者给我第二个选择.

c++ string int pointers

21
推荐指数
5
解决办法
13万
查看次数

标签 统计

c++ ×1

int ×1

pointers ×1

string ×1