Is this what you are looking for ?
Code:#include <string> #include <sstream> #include <iostream> using namespace std; template <typename T1, typename T2> T2 Convert(const T1 & t1) { std::stringstream ss; ss << t1; T2 t2 = T2(); ss >> t2; return t2; } int main(int argc, char *argv[]) { int array[] = {112, 113}; string s = Convert<int,string>(array[0]); int * arr2 = new int[s.size()]; for (int i=0; i<s.size(); ++i) { arr2[i] = Convert<char,int>(s[i]); cout << arr2[i] << "\n"; } delete [] arr2; return 0; }




Reply With Quote