How can I convert a string into an integer? I tried this: totalMins += atoi(MovieRecord->getMinutes()); Which I think only works for C-strings, and I tried this: totalMins += static_cast<int>(MovieRecord->getMinutes()); which I think only works for converting an int to a double or something similar.
rookieNeedsHelp
0
Newbie Poster
Recommended Answers
Jump to Postatoi does indeed only work with cstrings, however you can convert an std::string to a cstring using .c_str(). So for your example I would guess that the solution is:
totalMins += atoi(MovieRecord->getMinutes().c_str());
All 4 Replies
Labdabeta
182
Posting Pro in Training
Featured Poster
L7Sqr
227
Practically a Master Poster
mike_2000_17
2,669
21st Century Viking
Team Colleague
Featured Poster
rookieNeedsHelp
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.