Unless you've learned some sort of dynamic array (using vector or new[]/delete[]) my guess is that you're supposed to just come up with some maximum size for the array. So assume that the file will have no more than 1000 entries or something like that.
The thing you'd have to change with your code is identifying how to stop inputting. There is actually a simple technique for that.
Code:
while (infile >> array[i])
That will loop while there are numbers in the file. You'll have to adjust the code to count the number of items properly, but that should be a good starting point. Another option is to use the same technique in an if statement combined with your current for loop so you can break out of the loop if the read fails:
Code:
if (!(infile >> array[i]))