Converting 3 chars into a single int

If I have an String 107 and I'm turning it into a char so it's the digit symbols 1 0 7. Is it possible to turn it into an int of 107?
you can use sstream

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Example program
#include <iostream>
#include <string>
#include <sstream>

int main()
{
  std::string stringval("107");
  std::stringstream converter;
  converter << stringval;
  
  int intval;
  converter >> intval;
  
  std::cout << intval;
  
}
Last edited on
Topic archived. No new replies allowed.