Re: "C" beginner help ask:

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



have a look at the sprintf function

http://www.cppreference.com/stdio/sprintf.html

i.e.

char string[100];
int val = 909
sprintf(string, "%d", val);

wes

On 6/11/07, Gordiano <sagrav@xxxxxxxxxxx> wrote:
I want to convert a one or few digits integer in a string, for example
5557..., so each one of the four digits be a char, then a char array of
five elements (including the null one) makes the string.

I've tried with "cast", char pointers to an array, etc... but no good
results.
=================================
/* gcc -Wall temp.c -o temp */

int main ()
{
        int foo = 5557;
        char *cfoo[5];
        ... ????
        return 0;
}
=================================
thanks for help

misingo
www.astrocosas.com




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux