Author Topic: Not Installing C++11 Properly  (Read 2521 times)

thwikehu

  • Guest
Not Installing C++11 Properly
« on: December 12, 2015, 08:46:52 pm »
Edit: I'm trying to tell it to work with C++11 by clicking "Have g++ follow the C++11 ISO C++ language standard" in the compiler flags.

I'm getting stoi was not declared in scope, and I've added c++11 to Code::Blocks; I've added compatibility in Settings -> Compilers -> Compiler flags, but it still keeps giving me that error.

And when I try to do atoi or strtol I get the following error:

C:\Users\user\Desktop\Programming\NewProject\main.cpp|19|error: cannot convert 'std::string {aka std::basic_string}' to 'const char*' for argument '1' to 'long int strtol(const char*, char**, int)'|

My code:

Code
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <cstdlib>

using namespace std;

int main()
{

    string numberGuessed;
    int numberGuessedint = 0;

    do {

        cout << "Guess a number between 1 and 10: ";
        getline(cin, numberGuessed);
        numberGuessedint = stoi(numberGuessed);
        cout << numberGuessedint << endl;


    } while(numberGuessedint != 4);

    cout << "You win!" << endl;

    return 0;

}

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Not Installing C++11 Properly
« Reply #1 on: December 12, 2015, 09:52:29 pm »
It looks like your compiler does not (fully?) support c++11.
For me it works fine with gcc 5.3 on Fedora 23 64 bit.