#include #include #include #include using namespace std; const int MAX_LENGTH=20; const int MAX_SIZE=100; void FileOpen (ifstream &); bool ReadName(string &, ifstream &); void PrintNames(const string [], int); void Update(string [], int); int main(int argc, char *argv[]) { int size=0; string names [MAX_SIZE]; string temp; ifstream Infile; FileOpen(Infile); while (ReadName(temp, Infile)) { names[size]= temp; size++; } Update (names, size); cout << "Data updated\n"; PrintNames (names, size); Infile.close(); return 0; } void FileOpen (ifstream &Infile) { Infile.open ("lab3.input.txt"); if (Infile.fail()) { cout << "File doesn't exist\n"; exit(1); } } bool ReadName(string &temp, ifstream &Infile) { int size=0; bool moredata=true; if (Infile.eof()) moredata=false; else getline(Infile, temp); return moredata; } void PrintNames(const string names[], int size) { for (int i=0; i< size; i++) cout << names[i] << endl; } void Update(string names[], int size) { int i, loc; char dig1 ='0', dig2='0'; char FirstInitial=' '; string LastName="abc"; string newstring=""; for (i=0; i < size-1; i++) { //find method to find the space //set FirstInitial to the next location //use substr to get the three letters from last name //use string addition to put them together into newstring //Create digits by adding one to dig1 // If dig1 is a 9, then reset to a 0 and increment dig2 names[i]=newstring; newstring=""; } }