![]() |
Need help entering Values into an array from a file
I need to be able to enter these values
3 74 5 -14 62 71 -100 999 from a statdat.txt file into an array, int values[NUMELS] = {#, #, #, #, #, #, #, #) Im suppose to write a function that reads the values in one at a time and counts them as they are entered. This is what I have thus far. Code: CPP
any help would be greatly appreciated.. thanks |
Re: Need help entering Values into an array from a file
I think using vectors instead of arrays will be better in this situation.
Because you don't know the size of the list and count it while reading it, vectors will be much simpler to deal with than arrays. And, from your code .. I think you assume 999 to be the last of the numbers, you break there. So .. I have modified your code to this :: Code: CPP
I hope that will be useful. Offtopic comment: |
| All times are GMT +5.5. The time now is 15:23. |
(*) Please *always* post properly indented code, makes things easier for us.