-2

i want to convert two variables which are in type of char* to int in cpp

char* lower = "552"
char* higher = "882"

these two variables are number but in type of char* like "552" and i want to convert them to int like:

int e = 552 //which 552 is converted from char*

is CPP has a function to do this for me?

user3000968
  • 156
  • 1
  • 7
  • 2
    Was posting this really easier than typing this: `[c++] convert string to int` ?? Try [Convert string to int C++](http://stackoverflow.com/questions/7663709/convert-string-to-int-c). One of the many answers from that search. – WhozCraig Nov 22 '13 at 19:16

2 Answers2

0

http://www.cplusplus.com/reference/string/stoi/

#include <string>

void main ()
{
    char *lower = "552";
    int e = stoi(lower);
}
mb84
  • 683
  • 1
  • 4
  • 13
0

Yes, try sstream !

#include <sstream>
using namespace std;
void main()
{
   sstream s;
   char * lower = "552";
   int i;
   s<<lower;
   s>>i;

}
Archeosudoerus
  • 1,101
  • 9
  • 24