How to input a large number (a number that cannot be stored even in long long int) without spaces? We need this large number in an integer array such that every array element stores a single digit.
Input : 10000000000000000000000000000000000000000000000
We need to read it in an arr[] = {1, 0, 0...., 0}
In C scanf(), we can specify count of digits to read at a time. Here we need to simply read one digit at a time, so we use %1d.
Input :
27
123456789123456789123456789
Output :
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
We can also use above style to read any number of fixed digits. For example, below code reads a large number in groups of 3 digits.
Input :
9
123456789123456789123456789
Output :
123 456 789 123 456 789 123 456 789
Same concept can be used when we read from a file using
fscanf()