Extracting int for char array in C++
<p>I am trying to extract single character from char array and converting it in to integer.
I need to extract number from code for example if user enters A23B,I need to extract 23 and store it in a single variable here is my code</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
using namespace std;

int main()
{
char code[5] ={'\0'};
cout &lt;&lt; "Enter Your Four Digit Code\nExample A23B\n";
cin.getline(code,5);
cout &lt;&lt; "You typed:\n" &lt;&lt; code;
int a = atoi(code[1]);
int b = atoi(code[2]);
cout &lt;&lt; endl &lt;&lt;a &lt;&lt;"\t"&lt;&lt;b;
//Other processing related to number a and b goes here
}
</code></pre>

<p>but it's not working and produces the following errors</p>

<pre><code>C:\helo\clan\Test\main.cpp||In function 'int main()':|
C:\helo\clan\Test\main.cpp|12|error: invalid conversion from 'char' to 'const char*'|
C:\helo\clan\Test\main.cpp|12|error:   initializing argument 1 of 'int atoi(const char*)'|
C:\helo\clan\Test\main.cpp|13|error: invalid conversion from 'char' to 'const char*'|
C:\helo\clan\Test\main.cpp|13|error:   initializing argument 1 of 'int atoi(const char*)'|
||=== Build finished: 4 errors, 0 warnings ===|
</code></pre>
