converting an array of integers to string

Hello Friends,

I used to work as research assistant to my professor. I was doing a problem on facility layout in which i had to do many combinations of numbers like 20 numbers.
Initially it was easy as i did it with 4 digits like 1,2,3,4 so i could convert them to single digit 1*1000+2*100+3*10+4*1=1234. But for a 20 digit number it became cumbersome for me, so i decided to use strings. I researched the whole google to solve this problem, atlast i got the solution

#include <stdio.h>
#include <stdlib.h>
#include <sstream>
using namespace std;
int main()

int arr[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
std::string str;
//char buffer[20];
std::stringstream ss;
std::string s,st;

for(int i=0;i<20;i++)

ss << arr[i];



return 0;

you can all try these to....
really good
Last edited on
Topic archived. No new replies allowed.