Arrays in Files

Can someone explain to me how one would go about using arrays to add or sort things from files. So I understand arrays, say this is to initialize and define it: int numbers[4] = {23,46,12,35}; what I don't understand is what you would do if you didn't know how many things you wanted to replace, therefore how would you know the subscript and how would you be able to read in the "numbers" from the file. Also say if you were to sort changing numbers, then you wouldn't know the "{23,46,12,35} part.
You can eighter assume a maximum capacity like 100 and no more
or you create the array dynamically (with new[]) when you know the size
or you use standard container like vector
Topic archived. No new replies allowed.