Hello Everyone.

Having some problem with coding, and hoping that someone could help.

I have a text file with input delimited by spaces. Something like this:

TGP C 18 3.90 4737
JWW B 25 6.5 9630

Now I can open and read the file. Now I am trying to get specific information from each line, so that I can dump them into another function I created. For example the 18 & 25 above are ages. I have to take that information and depending on the age have a different output.

18 - Group 1
25 - Group 2

I already have the functions ready, just can't figure out how to separate the lines. I am thinking an array would help, but still can't figure it out.

9 Years
Discussion Span
Last Post by Ancient Dragon

I'm not sure what you are asking. Do you need to save the ages for later? If not, then you don't need arrays

ifstream in("filename.txt");
std::string name;
std::string grade;
int age;
while( in >> name >> grade >> age )
   if(age > 50)
      cout << "Group 4";
   else if( age > 40)
      cout << "Group 3";
  // etc etc
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.