[ create a new paste ] login | about

Link: http://codepad.org/oYuwXLFj    [ raw code | output | fork ]

C++, pasted on Nov 18:
uint8_t NumberToDigits( unsigned long number, char* digits )
{
 sprintf( digits, "%lu", number );
 uint8_t
  i = 0,
  n = strlen( digits );

 while ( i < n )
  digits[i++] -= '0';

 return n;
}


int main()
{
 char digits[12];
 uint8_t
  i = 0,
  n = NumberToDigits( 945613278, digits );

 while ( i < n )
  printf( "%d\n", digits[i++] );
}


Output:
1
2
3
4
5
6
7
8
9
9
4
5
6
1
3
2
7
8


Create a new paste based on this one


Comments: