Most of the information I've found is based on numbers, however I want to use words. For instance, if my text file looks like this:
M
Gordon
Freeman
Engineer
F
Sally
Reynolds
Scientist
I want to be able to put each line into an array and output it like so:
Gender: M
First Name: Gordon
Last Name: Freeman
Job: Engineer
Gender: F
First Name: Sally
Last Name: Reynolds
Job: Scientist
This list could go on and on, but two is good for now.
I'm currently using a struct to hold the information:
struct PeopleInfo
{
char gender;
char name_first [ CHAR_ARRAY_SIZE ];
char name_last [ CHAR_ARRAY_SIZE ];
char job [ CHAR_ARRAY_SIZE ];
};
I'm not sure if I need to use a delimiter or something to tell the program when to stop at each part (gender, first name, last name, etc). Could I use the getline function with ifstream? I'm having trouble implementing that in my own code. I'm not really sure where to start as I haven't had to use anything like this for a while now. Frantically searching through textbooks and Google to find similar problems, but so far I haven't had much luck. I will update my post with any questions and code that I discover.