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...
thank
ledox
0
Newbie Poster
Recommended Answers
Jump to Post>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.
Jump to Post>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 …
All 5 Replies
blazted
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
WolfPack
commented:
best answer
+8
ledox
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
blazted
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.