converting ints to strings?
What is the completely easiest way to convert an int to a string? I have heard of classes such as stringstream but i am wondering if there is another approach ? (i assume theres nothing like in java, with an integer wrapper class?)
for example what if i wanted to save the string "0" to my array slot 0, and "1" to my array slot 1?
Code:
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int sz;
cin >> sz;
string *arr = new string[sz];
//for loop that converts its index to string SOMEHOW(?), and saves it to arr[i]
for(int i =0 ; i < sz ; ++i)
{
arr[i] = i; //Wrong
cout << arr[i];
}
}
thanks!
:)
edit: also thought about that since a string is actually a char pointer array(from what i hear!) that I can just cast a char to an int? is that way?