I am trying to write a program that reads text from a file and then stores that text. The file consists of lines that have information in this order NAME [space] JOB [space] SALARY [space] CITY [new line], for multiple people.
I know how to open and read the file, but since my program has to ask the user if he/she wants to see all the cities and/or all the jobs etc i have to store the first word of every line together and the second word of every line together etc. That way if the user asks to see the cities I can simply output the array or string where I stored all the cities. I am not sure how to do that part, could someone show me the right direction. I don't want a solution, but maybe suggestions of which commands to use to store the information separately by category. Thanks a lot.
What you want is to create a class that you might call Person, with each instance of class Person able to hold all of those parameters. To store all of these "Person" objects, you would create a vector of Person objects. To output all of the cities, you would simply loop through every object in the array and use a method of the class you created that would output the city.