Is this a good way to use a string for int operations?
I'm trying to use a string like an int as well as a string. For example, I have to pass my string through a for loop. My code works, but I get the nagging feeling that there's a better way out there.
using namespace std;
string x = "0";
for (int i = atoi(x.c_str()); i<10; i++)
x = ss.str();
This is just a proof of concept I wiped up. Is this the 'right' way to go about it?
|I'm trying to use a string like an int as well as a string.|
I can understand wanting to do that with a char, but not a string.
A char is just a small int, so you can do calculations with it.
Topic archived. No new replies allowed.