I want to know new ways to do it, this is my solution.
arr[nccard - i] = (long long)(ccard / pow(10, i - 1)) % 10;
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.Sign up to join this community
You can use a loop. As long as the number is not zero, process its last digit (
%10), for example storing it in an array, then divide the number by 10, shifting decimal digits to the right. If you intend to use the original number later, operate on a copy of the number instead, as this process is destructive.
That's much more efficient than using floating-point power function and converting back to long long int.
Another way could be to read a string instead of numbers, and process the digit characters, subtracting
'0' from each of them.