how can I separate the characters of a number by taking each number singularly? I have the number 842 and i need to separate it into 8, 4, 2.
Asked
Active
Viewed 42 times
0
-
Also https://stackoverflow.com/questions/15987666/converting-integer-into-array-of-digits – Suraj Rao Mar 08 '22 at 10:53
1 Answers
0
- Take the input as a string
- Iterate over it character by character until the end of the string (the null terminator).
- Convert each digit from ASCII to integer by subtracting the value
'0'
from it.

Lundin
- 195,001
- 40
- 254
- 396