Given an input from the user (ex. 123456) you must convert the input int to an int array (ex. {1, 2, 3, 4, 5, 6}.
I was wondering, how can this be done? I have started out with a function that counts the digits the were inputted, and initializes an array with the amount of digits.
Is there another way to go about doing this that is simpler?
This is what I have so far:
#include <iostream>
using namespace std;
int main()
{
int n, counter = 0;
cin >> n;
while (n != 1)
{
n = n / 10;
counter++;
}
counter += 1;
int arr[counter];
return 0;
}