title: Converting char to int in C++
body: <p>I'm trying to convert a character from a c string to an int but I keep running into an error.</p>
  
  <p>Here's my code</p>
  
  <pre><code>while(std::getline(file, line)){
              if(std::isdigit(line[0]) &amp;&amp; std::isspace(line[1]) &amp;&amp; std::isdigit(line[2])){
                  SequenceArray.push_back(line);
                  if(std::stoi(line[2])== (SequenceArray.size() -1)){
                      std::cout&lt;&lt; "Success" &lt;&lt; std::endl;
  </code></pre>
  
  <p>The error that I keep getting is as follows:</p>
  
  <pre><code> a1.cpp: In function ‘int main(int, char**)’:
  a1.cpp:30:25: error: call of overloaded ‘stoi(char&amp;)’ is ambiguous
       if(std::stoi(line[2])== (SequenceArray.size() -1)){
                           ^
  a1.cpp:30:25: note: candidates are:
  In file included from /usr/include/c++/4.8/string:52:0,
                   from /usr/include/c++/4.8/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8/bits/ios_base.h:41,
                   from /usr/include/c++/4.8/ios:42,
                   from /usr/include/c++/4.8/ostream:38,
                   from /usr/include/c++/4.8/iostream:39,
                   from a1.cpp:1:
  /usr/include/c++/4.8/bits/basic_string.h:2823:3: note: int std::stoi(const string&amp;, std::size_t*, int) &lt;near match&gt;
     stoi(const string&amp; __str, size_t* __idx = 0, int __base = 10)
     ^
  /usr/include/c++/4.8/bits/basic_string.h:2823:3: note:   no known conversion for argument 1 from ‘char’ to ‘const string&amp; {aka const std::basic_string&lt;char&gt;&amp;}’
  /usr/include/c++/4.8/bits/basic_string.h:2926:3: note: int std::stoi(const wstring&amp;, std::size_t*, int) &lt;near match&gt;
     stoi(const wstring&amp; __str, size_t* __idx = 0, int __base = 10)
     ^
  /usr/include/c++/4.8/bits/basic_string.h:2926:3: note:   no known conversion for argument 1 from ‘char’ to ‘const wstring&amp; {aka const std::basic_string&lt;wchar_t&gt;&amp;}’
  a1.cpp:35:6: warning: label ‘std’ defined but not used [-Wunused-label]
        std:exit(EXIT_FAILURE);
  </code></pre>