I want to convert my command-line char* argv[] argument to int. I am studying to OpenCV and there it used like this:
int main(int argc, char* argv[])
{
int divideWith = 0;
stringstream s;
s << argv[2];
s >> divideWith; //This is my argument converted to int
}
It used a stringstream class. Is there any other way to convert strings (char arrays) to int. I already know to do this:
char a = '7';
int b = a;
In here it asigns the ASCII representation to my int variable. I want it to be like this:
char a = '7';
int b = somefunction(a); //A function, algorith or what ever that returns an int '7'
cout << b;
This should give me the 7 result in comand-line.