Is there a way to input n
of inputs into an array, where n
is not fixed, using scanf()
?
scanf("%d %d %d %d ... n number of inputs", &array);
The problem is that a user enters the size of an array, and the input format is that the inputs are stored using scanf
in a single line, so it is of the form
12 24 36 34 65 24 54 ... upto n inputs
So that the first %d
is stored in array[0]
, the second into array[1]
, third into array[2]
, and all the way upto array[n-1]
.
It is easy to make a for
loop for this, but I want to do it in a single line.