I was recently creating a program and trying to convert a string to an int (similarly to Integer.parseInt(x) in java) and wasn't sure if there was a c++ equivalent that i could use?
doomsday1216
0
Newbie Poster
Recommended Answers
Jump to Postone way to convert an int is to use the a string streams. Another way is to use the function atoi().
#include <sstream> // for stringstream #include <iostream> #include <string> #include <cstdlib> // for atoi() using namespace std; int main() { int a, b; string number = …
All 2 Replies
NathanOliver
429
Veteran Poster
Featured Poster
mike_2000_17
2,669
21st Century Viking
Team Colleague
Featured 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.