My c++ code

string map = "111111111111111111111111111"
for (int i = 0; i < 20; i++)
{
   int number = atoi(map[i]);
}

Gave me error: cannot convert parameter 1 from 'char' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

string map = "111111111111111111111111111"
 
for (int i = 0; i < 20; i++)
{
   std::istringstream ss(map[i]);
   
}

Gave me some error too.

How should I do that?

Amount if 1 in string is 300 so int value would be huge thats why I have to take single letter.

Edited 6 Years Ago by Hektzu: Typos

So you want to convert it into an int array?

No I want take one letter and convert that to integer. If that is not possible I have to use array or vector and size would be big.

No I want take one letter and convert that to integer. If that is not possible I have to use array or vector and size would be big.

char n1 = '1';
int num = n1 - '0'; //num equals 1
This question has already been answered. Start a new discussion instead.