convert an integer number into an array

Posted by droseman on Stack Overflow See other posts from Stack Overflow or by droseman
Published on 2009-02-05T12:00:34Z Indexed on 2010/04/03 11:03 UTC
Read the original article Hit count: 246

Filed under:
|
|

Hi,

I am trying to convert an integer number in C into an array containing each of that number's digits

i.e. if I have

int number = 5400

how can I get to

int numberArray[4]

where

numberArray[0] = 0;
numberArray[1] = 0;
numberArray[2] = 4;
numberArray[3] = 5;

Any suggestions gratefully received

--dave

© Stack Overflow or respective owner

Related posts about c

    Related posts about arrays