How to create an array given a line of input with integers where the first integer is the length?

I am trying to create a function that returns the address of an array which is created by taking a single line of input from the user where the first integer is the length. For example if the input from the user was “5 19 8 26 12 9” the corresponding array would be [19, 8, 26, 12, 9] (Which is of length 5).

The way I went about doing this was rather than taking input from the user while after the function ran I took it as arguments (argc,argv) Ex. “./a.out 5 19 8 26 12 9”. I was wondering if there were any other possible solutions that exist perhaps using scanf or cin…