For example take 123 and put it into an array where that is a[3] = {1, 2, 3}?
Without converting it to a string and iterating over it.
You can get the decimal digits of a number by using integer division and modulo.
//Pseudo code
int[MAX_SIZE] result;
int index = 0;
while (workingNumber > 0)
{
digit = workingNumber % 10;
result[index] = digit;
workingNumber = workingNumber / 10; //Must be integer division
index++;
}
First, keep in mind that in C the only real difference between "array of char" and "string" is to be a string, you put a NUL-terminator at the end of the array of char.
Assuming you wanted (for example) to create an array of int (or long, or something else other than char), you'd typically take the remainder when dividing by 10 and convert it to a digit by adding '0'. Then divide the number by 10 and repeat until it's reduced to zero. That creates the numbers from least to most significant, so you normally deposit them at the end of the array and work backward toward the beginning.