create a test file called bio.txt // the file will have the following format: // lastname age // lastname age // ... // read this file and create two arrays // one array should contain the last name of all seniors (age >= 65) // the other array should contain the last name of all children (age < 18) // print out both arrays // example: // jones 84 // michaels 16 // fredrickson 22 // mitchell 7 // franklin 45 // johnson 77 // the result would be: // seniors: // jones // johnson // children: // michaels // mitchell
Explanation / Answer
#include #include #include using namespace std; void createfile(){ string dat="jones 84 michaels 16 fredrickson 22 mitchell 7 franklin 45 johnson 77"; ofstream make("bio.txt"); makeage; if(age>=65){ Seniors[seniorCnt]=lname; seniorCnt++; } else if(age