Hi, I am trying to write a program for uni that will read two different .txt files and output some data about them. I am fairly confident I can do this I just cant figure out what arguments to pass to my functions to read the files properly?
students.txt is a long file, with one word on each line. If someone can point me in the right direction on how to properly pass the correct arguments across I am confident I can right the code in the functions to output the data.
1 //number of entrys
The typical way is to call something like getline in a loop to read from the ifstream and store the result into an array. It's up to u. The way u'r going u'll have to create a bunch of Student instances and pass each one into readStudents which could take a lot for memory.
Line 26 doesn't make sense because u'r passing a structure and not an instance of it. This makes more sense, for example:
thanks for the reply, that newstudent does make a lot more sense but would that run through my for loop to however many students was in the .txt? or would I have to create more instances like newstudent1 etc? (which would kind of defeat the purpose of the loop) lol. I think I am just a little confused on where they are supposed to get stored, if they should even get stored?
I am only supposed to read the file once and yeah I think I would have used a getline but we are not supposed to use functions that we have not yet covered. Just so annoying I cant even try and write the rest of the code because its not even reading the .txt in
i thought mine was solved but its not... I'm having problems storing the info. I want to store certain lines from the txt into an array so I can access the info later but just cant figure out how to do this..
Thanks for the help my codes changed quite a lot, find it hard to get the private and public and what's available around my head. ^It looks a bit confusing but I think its similar to what I have, but i'm still very confused on how to actually store values so they can be accessed later? Here is my whole program