Question: I need help creating a function that does this please help in c++. Libraries included are: iostream, fstream, vector, sstream, string, cmath Please and Thank

 I need help creating a function that does this please help

I need help creating a function that does this please help in c++. Libraries included are:

iostream, fstream, vector, sstream, string, cmath

Please and Thank you.

void readFile( ifstream & inFile, vector &item, int& count); inFile - already open file to be read item - vector to store data count - the number of records read This function uses the previously opened filestream to read in the data from the file. You must use getline() to read the data from the file with a "n'as the terminating character. Once the line of data has been read, use getNextField() to parse the line, one field at a time. The initial call after the getline should have the index set to zero, so it starts at the beginning of the string. getNextField( will update the index, so it won't need to be reset to zero until after the next call to getline(). The data should be read until end of file is reached. See example output. The function should start with a locally declared and initialized AISType temporary record. As the line is read/parsed and the fields are parsed, set the corresponding value in the temporary record. Once parsing the line is complete, and the temporary record is filled, use push_back() to add the temporary record to the AISType vector. Reset all values in the temporary record to default before reusing the temporary record on the next line. The function must keep a counter of the number of records read. The counter is used for outputting the number or records read. readFile() uses the following C++ functions getline() - C++ library getNextField() - student provided saveField() - student provided Algorithm for readFile 1. use getline() to read the line into a string 2. check for eofo 3. set index to 0, fieldNumber to 0 4. call getNextField() on the string read in 1, passing index, and a string to receive the field 5. use saveField() to store the data in a temporary struct of type AISType (use fieldNumber to determine which field gets the data) 6. increment fieldNumber 7. loop back to 4 until the entire string has been processed. 8. add the temporary struct holding the data to the vector using .push_back 9. reset fieldNumber and index to 0 10. loop back to 1 till eofd To get the progress count, place the following code at the bottom of the read loop. // Output the number processed. If the number update stops, then // their may be problem with the program. char eraseLine[]={" ',27, '1','1','K'}; if( (count % 100000) == 0X cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!