string - C++ stoi out of scope issue -


i using latest version of c++ , trying run following code. however, keeps telling me stoi "not declared in scope". new c++ please share if have ideas.

#include <iostream> using namespace std;  #include <iostream> using namespace std; #include <string>    int main(int argc, char *argv[]) {  int a; (int i=0; i<argc; i++) {     string str(argv[1]);      a=stoi(str);      if (a<1) {        cout<< "the sequence length must greater 1"<<endl;    } else {        cout <<"consecutive "<< a<<endl; // prints input number of required consecutive    } }  int num[1000000]; int n, j; n=1;  (int x=1;!cin.eof() ; ++x) {     cin>>num[x];      if (cin.fail())     {         cout<< "error, integers allowed"<<endl;     break;     }       else if (x>=a)      {         while ( num[x-n+1] - num[x-n] == 1)          { ++n;          if (n == a)         { cout<< "sequence found: " ;          (j=a-1; j >=0; --j)              cout<< num[x-j]<<" ";         break;         }         }     } }  cout<<endl; return 0; } 

std::stoi c++11 , above feature, hence enable c++11 on compilation.

in gcc or clang, flag -std=c++11

cxx -std=c++11 cc.cc 

where cxx either g++ or clang++.

please make change also, in header inclusion part

#include <iostream> #include <string> using namespace std; 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -