Is there a fast way to store a number in an array like:
Input: 234586349
becomes
Code:
int array[] = {2,3,4,5,8,6,3,4,9}
Right now my method is very tricky :/
To get the 6, I have to do:
Code:
int a= 234586349 / static_cast<int>(pow(10.0,3)); // gives 234586
int b = (234586349 / static_cast<int>(pow(10.0,4))) * 10; // gives 234580
int x = a-b; // gives 6
Then somehow I have to use a FOR function to get all the digits... is there a better way?
(Preferably one that doesn't involve floating numbers and static_casts I always get into trouble around them >_<)
Thanks!