Function stoi not declared
stoi
is a C++11 function. If you aren't using a compiler that understands C++11, this simply won't compile.
You can use a stringstream
instead to read the input:
stringstream ss(hours0);
ss >> hours;
The answers above are correct, but not well explained.
g++ -std=c++11 my_cpp_code.cpp
Add -std=c++11 to your compiler options since you are most likely using an older version of debian or ubuntu which is not using by default the new c++11 standard of g++/gcc. I had the same problem on Debian Wheezy.
http://en.cppreference.com/w/cpp/string/basic_string/stol
shows in really small writing to the right in green that c++11 is required.
std::stoi
was introduced in C++11. Make sure your compiler settings are correct and/or your compiler supports C++11.