cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
read from file to array
read from file to array
Mar 1, 2012 at 11:05am UTC
gitaristas
(1)
Hello. Sorry for my poor english.
I have a file of such data
Faculty, student name , last name , grades number, grades ..
example:
faculty john berdy 3 5 6 8
faculty John Smith 5 6 6 6 5 4
faculty just fun 2 4 2
as we see the first figure is the amount of grading, and then folow grades. How can i read it to array, because each line is different.
Then will i have the array I have to find the grade average.
Thank you for the help, really.
Mar 1, 2012 at 11:34am UTC
Gaminic
(1621)
Easiest way would be to make a vector
[1]
of grades, rather than an array, because a vector can grow (and shrink) when needed. Then, it's just a matter of reading in the data (which I will leave for someone else, because I'm terrible at I/O stuff).
[1]
http://www.cplusplus.com/reference/stl/vector/
Topic archived. No new replies allowed.