I'm new to programming, and I'm wondering, how can I know the number of digits in an integer that the user enters? For example: the user enters a number like 123456, how can I know that the user enters 6 digits?  I don't want to use a for loop to get user input because I don't want the user to enter each digit after a space or enter.
Right now, I'm converting a number to an array of digits so I can have control over them, but the issue is that I don't know how many digits I should loop over, because I don't know how many digits are in the number.
Can I get the user's input as a string and then use string.length and convert it to an array of digits?
#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    while(N--)
    {
        int num;
        cin >> num;
        int arr[1000];
        for (int i=0 ;i<???;i++)
        {
            arr.[i]=num%10;
            num = num /10;
        }
    }
}
 
     
     
    