read a text file into a class

would it be possible to get the text file into the class format
Are you saying you want to change the data inside the text file?

It sounds you'd rather want to keep the data file the same and just parse it correctly.
Look into getline and my_file_stream >> my_int_variable

If you have an open file (ifstream), you can call
getline(my_file, token, ',');
This will parse the file until it reach a ',' character, and put the contents before the comma into the variable called 'token'.

By default, getline delimits on a newline (hence the name).

https://www.learncpp.com/cpp-tutorial/basic-file-io/
https://stackoverflow.com/questions/19107439/c-getline-multiple-variable-types-using-comma-as-delimiter

rbradders1 wrote:
i have tried to read it into a group of vectors which i have successfully managed but then i cannot return the vectors back to the class as you can only return one value from a function
Show us what you've tried. It sounds like it might be a easily fixed point that you're getting hung up on.
Last edited on
Is this a homework assignment? Or work related?

Because creating a secure password for your users is significantly more involved than you probably want to deal with if this is just homework.
Topic archived. No new replies allowed.