so I want to run a for loop with scanf() to read the elements of an array in one line. But the problem is that scanf() keeps going to the next line. I want to get around this. Also, I cannot just write scanf("%d%d%d...%d", &x1, ..., &xn) because the length of array is variable and must also be input from the user.
I tried searching on the internet, but to no avail. I briefly considered the y[i]=getchar() function, only to immediately realize that getchar() is the epitome of new line commands.