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

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

Lots of good resources on the web on that. Google "C++ resize array". The top of the list is actually a thread from Daniweb. Look at post number 4 in this thread.

http://www.daniweb.com/forums/thread13709.html

k i got it!!
thanks :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.