Could anyone explain how to write this sample program correctly. I need to
convert an integer to a string. However, I would prefer to convert the
integer to char array. But I didn`t want to use "itoa".
And I am not that familar with using "stringstream". And is there better
approach to converting integers to char arrays.
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
char StringTest(int);
void main ()
{
int num = 123456789;
char num_ch = StringTest(num);
cout<<num_ch<<endl; //***this is to test print***
}
char StringTest(int num)
{
stringstream test;
test << num;
string int_str = test.str();
return int_str; //***needs to convert to char***
}