-2

I get the error: 'stoi' was not declared in this scope.

#include <string>
using namespace std;
...
int x;
x = stoi(arg[0]);

I am running Code::Blocks 16.01 on Windows 10 with the -std=c++11 setting.

I didn't find any useful information on this page: ‘stoi’ was not declared in this scope

I saw somewhere that upgrading gcc can fix this problem, but I didn't find an appropriate installation on the page: https://mingw-w64.org/doku.php/download

The same code works fine in Code::Blocks 13.12 on Linux Mint 17.3.

Is there a recommended fix for this problem? Can this be fixed by using the 64 bit version of MinGW (assuming that is compatible with Code::Blocks 16.01)?

Update there is a workaround, using atoi and c_str instead:

x = atoi(arg[0].c_str());
Community
  • 1
  • 1
gornvix
  • 3,154
  • 6
  • 35
  • 74

1 Answers1

2

I believe that this is a bug with MinGW. For more information, check out this StackOverflow post. Specifically, DRH's answer.

Community
  • 1
  • 1
NoseKnowsAll
  • 4,593
  • 2
  • 23
  • 44