I am compiling a code, but I seem to get an error, even as I examine my code, I find it weird that I'm getting this error.
My code:
#include <iostream>
#include <string>
using namespace std;
int main() {
string s = "2A";
int n = stoul(s, nullptr, 16);
cout << n << endl;
return 0;
}
and in the command line, I'm typing g++ -std=c++11 main.cpp
, I'm using -std=c++11
because the function stoul
is from C++11
according to this page stoul.
The error I'm getting is the following:
main.cpp: In function 'int main()':
main.cpp:8:30: error: 'stoul' was not declared in this scope
int n = stoul(s, nullptr, 16);
^
Why am I getting this error?