I'm working on a program where I'm using stoi to convert strings and getting the error in the title. I'm compiling using g++ version 7.3.0 on Ubuntu. The full line I'm entering to compile is g++ -c -std=c++11 -Wall -ansi -pedantic test.cpp
Below I included a minimal version of my program that produces the same error.
test.cpp
#include <iostream>
#include <stdio.h>
#include <vector>
#include <fstream>
#include <string>
int main(){
std::string string = "12"
int num = std::stoi(string); //this line causes error
std::cout << num << std::endl;
}
error
test.cpp: In function `int main()`:
test.cpp:9:20: error: 'stoi' is not a member of 'std'
int num = std::stoi(string);
^~~~
I'm not sure what could cause this issue, I realize that some of the things i'm including at the top aren't necessary for this program but I just copied them from my actual program into this reproducible example in order to keep everything consistent. Could this be an issue where the compiler Isn't compiling with c++11? I thought the -std=c++11
flag would work but I'm relatively new at this so i could be wrong. Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire