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.

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
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.