Get individual numbers from int

Hey guys, i'm writing a small math app and i need a little help.

let's say i saved a users input into a variable (int), and i wanna get the individual numbers from the int itself, lets say the input is "2468", i wanna be able to get each of em alone...as if it were an array.

The only way i can think of is to make the user write a number then press Enter, four times if the numbers length is four...which is rather silly.


Thx :)
2468 % 10 = 8 is the last digit

2468 / 10 = 246
246 % 10 = 6 is the third digit

and so on. (do it in a loop)
Awesome, i hoped there were some math trick like that :D

Thank you!.
Topic archived. No new replies allowed.