Hi,
knowing that my main program starts with int main(int argc, char *argv[]) and that my arguments are decimal numbers, how can I easily (without entering too many more lines of code) interpret them (under their char *argv[] form) as such?
Purpose:
Eventually I'd like to evaluate a comparison such as: (argv[4]<argv[3])
(like in an if cell)
With C++11, you can use std::stoi to convert the arguments to int, e.g.: if (stoi(argv[4])<stoi(argv[3]))
Without C++11, you can use boost::lexical_cast or std::stringstream (or atoi).
Thank you very much.
It seems to be working with stringstream, but I'm now noticing that I'd need the absolute value of one of this decimal numbers, do you know how I can do that (beside abs from <math>) ?
Thank you
I resolved this.
But no, actually I just noticed that stringstream(argv[4])>stringstream(argv[3]) does not compute. I don't know why, but it doesnt...
I'll try some of the others.