Hello ,,,

Please I need Your Help as soon As Possible..

I have an array of integers and i need to convert it to string ...


PlZ Help me as soon as Possible ...

Could we see an example of the code you tried?

take a look here

you will need to loop through the array with a for loop

How is that your code? That's a reference link to strcat.

i have do a dynamic array of integers and i store the values.

for(int i=Count-1 ; i>=0 ; i--)
    {
    Digit[i]=(str[i]-'0');
    }

this is my code first i convert string to array then i need to convert it back to string after doing some operations >>>

plz help

Hello charming--eyes,
Do you want a string like "7456" if the integer array a[5] has a[0]=7,a[1]=4,a[2]=5,a[4]=6 ?

std::stringstream out;
    for(size_t i=0; i < size; i++)
    {
        int x = digit[i];
        x = x >> i; // do something to digit
        out << x;
    }

Hello charming--eyes,
The ASCII value of numeric characters start from 48 which refers to 0.Add the integer and 48,then store it in the character array.

int a[100];
char a[100];
a[0]=48+f[0];

For example if f[0] has 7,then 48 +7 = 55.So a[0] will take up the ASCII value as 55.
Put this in a loop. You will have the integers converted to string.

commented: Thanks +1

Thank you very Much >>Arbus>>


my problem has been solver

How is that your code? That's a reference link to strcat.

Err, I'm not the OP... I was trying to help him by pointing him to a method of combining strings.

**Basic Code in C Language**


#include<stdio.h>
#include<malloc.h>
void int_to_char_array(int *arr,int arrLen,char *str)
{
    int count=0;
    while(count<arrLen)
    {
        if(*(arr+count)/10!=0)
        {
            *str++=*(arr+count)/10+'0';
            *(arr+count)%=10;
        }
        else
        {
            *str++=*(arr+count)%10+'0';
            count++;
        }
    }
    *str='\0';
}

void main()
{
    int *arr,arrLen,count;
    char *str;
    puts("Enter size of int array :");
    scanf("%d",&arrLen);
    arr=(int *)malloc(sizeof(int)*arrLen);
    str=(char *)malloc(sizeof(char)*arrLen);
    puts("Enter elements of int array :");
    for(count=0;count<arrLen;count++)
        scanf("%d",(arr+count));
    int_to_char_array(arr,arrLen,str);
    puts("Main Result :");
    puts(str);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.