I have a very simple main.cpp file:
#include <iostream>
#include <string>
using namespace std;
int main() {
string s = "194";
int i = stoi(s);
cout << i << endl;
}
In the command line clang++ main.cpp -std=c++11
outputs:
main.cpp:6:10: error: use of undeclared identifier 'stoi'
int i = stoi(s);
^
1 error generated.
and clang++ --version
outputs:
clang version 3.6.1 (tags/RELEASE_361/final)
Target: i686-pc-windows-gnu
Thread model: posix
And with GCC, g++ main.cpp -std=c++11
outputs:
main.cpp: In function 'int main()':
main.cpp:6:16: error: 'stoi' was not declared in this scope
int i = stoi(s);
^
with g++ --version
outputting:
g++ (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
I've tried looking at answers to similar questions, but none of the solutions seem to work.
What could be the problem?