# Combine numbers in string

• 12-09-2005
gtr_s15
Combine numbers in string
hi, can someone help me on the problem that i had:

Problem:

the string output is:4488118417,
and i split it to two: 44 88 11 84 17,
and how can i make 44 in one string, usually 44 is str[0] and str[1].

for example

str[0]=44
str[1]=88
str[2]=11
str[3]=84
str[4]=17

This is the code that i stuck with:

Code:

```    stringstream numbers; /* Insert integer into stringstream*/     numbers <<numLowerCaseLetter(name)<<sumAscii(name)<<lastValue<<counter<<sum; /* Convert stringstream into string.*/     string str = numbers.str();     if(str.size() % 2 == 0)     {         for(int i = 0; i < str[i]; i=i+2)         {                 cout<<str.substr(i,2)<<" ";          }     }        else     {                 str.size()+1;         str.append( 1, '0' );                 for(int i = 0; i < str[i]; i=i+2)         {             cout<<str.substr(i,2)<<" ";         }```
• 12-09-2005
sunnypalsingh
Try This
Code:

```#include<iostream> #include<string> using namespace std; int main() {                 string str="12345678";         string array[5];         int i=0;         int k=0;     while(i<str.size()-1)     {         array[k]=str.substr(i,2);                 cout<<array[k]<<endl;                 i+=2;                 k+=1;         }            return 0; }```
• 12-09-2005
gtr_s15
wow.. thank you very much,,, u are such a genius.... very appreciate on what u done...