u ask user for the filename
and then u read the the file, display it into an array
assume file contain only numbers
with that u display data such as total,average,highest number,lowest ect..

my question is how would u determine the size of an array to work with?? given the filename


in my code i set array size to 10
but if the file is not extally 10 number then it wouldnt work peferctly

is there a way to solve this??

u ask user for the filename
and then u read the the file, display it into an array
assume file contain only numbers
with that u display data such as total,average,highest number,lowest ect..

my question is how would u determine the size of an array to work with?? given the filename


in my code i set array size to 10
but if the file is not extally 10 number then it wouldnt work peferctly

is there a way to solve this??

If you have no way of knowing how many elements are in the file, you'll need to have the ability to resize the array dynamically as you are reading from the file. You can do that yourself, but the easier way is to use a vector, which does all of the resizing for you.

http://www.cplusplus.com/reference/stl/vector/

how would you resize the array as u reading the file?
cause we havent learn vector so i dont think i can use it

This article has been dead for over six months. Start a new discussion instead.