hi, i have a another question about converting char to int in C++.
if i have char n="123" and char n2= "87" and i wanna sum those two char...how can i do that? i know i have to change each char in int but for the rest...
>You can use atoi to convert the char to a int
Or not, seeing as how atoi is a demon spawn. Use strtol instead, or since this is C++, stringstream or Boost::lexical_cast. Examples are common and can be found with this forum's search feature.
i tried the function atoi() and i think it only works for char and not for string.
what i'm trying to do, its to ask the user to enter two numerics number in string type and add those two strings and the result must be a integer.
>i tried the function atoi() and i think it only works for char and not for string.
Well there's your problem. You're guessing. "I think it only works for <yadda yadda yadda>". :icon_rolleyes: It works perfectly for string types, assuming you know what a string type is and which one atoi accepts, except for the fact that atoi is horribly BROKEN! I mean, really. Do you people try to pick the worst possible option out of any list of choices I offer?
>i tried the function _toascii()-48...
... Yea, maybe you should post your code so that someone clueful can help you make it right.