I have to use parallel arrays to make this phone directory program. I was just wondering if their is a better way to do something this is a sample of my input.
9768 N. Adrian Hwy
Detroit Mi, 48719
So since arrays can only have one type I and since I might need to up date the info later I decided that I should have a first name array a second name array an int array for the street address(9763)
Arrays for all the different types one array for for city and state one for zip. You get the idea I'm sure. But this seems kind of stupid. And tedious. I was going to to do a function to get each one then put that in a loop and have it just do it while the file isn't empty. Does this seem like to much work?
double midterm, final;
// Function to write the grades to the struct
istream &read(istream &is, student_info &s)
is >> s.name >> s.midterm >> s.final;
cout << "If you would like to stop entering the students" <<
"info at any time just enter end of file (CRTL Z)" << endl;
cout << endl;
while (read(cin, record))
This is some simplified code from accelerated C++ (Didn't wanna type out all the functions and stuff ;p) but I think you get the idea. If you still aren't familiar with struct you can check it out here on this website (Just enter struct into the search).
EDIT: Wait a second the code I just copied and pasted was just in another topic of yours talking about struct lol so you should know all that already ;p.
OH, the directions say that it has to be in parallel arrays. So I don't think I can use that. Thanks anyways would be nice to be able to use that though.
Or can I? Isn't that still an array? Because of the Person people? It's just one array? Hmmm. I'm not sure.