I'm trying to use stoi
to convert a string to an integer, however it says it's not declared. I have the standard library and the <string>
included, but it still says [Error] 'stoi' was not declared in this scope
The code is the following:
#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;
}
Either tell me why it isn't working, or give me a second option to do it, please.