Write a function that reads data from a file. The file has already been opened and verified. The data should be saved in the array of type ship. The size of the array is passed in the int parameter and the number of records read is return in the last parameter, by reference. The file should be read until end of file has been reached or the array is full. struct ship{ string shipCaptain; string shipName; }; The function prototype is void readFile( ifstream&, ship[ ], int, int& ); ifstream - The already open file ship[ ] - array of structs where the data from the file will be stored. int - the size of the array. int& - the number of records read from the file. This value is set by the function before returning return- the number of records read from the file, returned by the function. The amount of data in the file is unknown but there is no bad data. The file format is the shipsName followed by the shipsCaptiain .
(FRP7) Write a function that reads data from a file. The file has already been opened and verified. The data should be saved in the array of type ship. The size of the array is passed in the int parameter and the number of records read is return in the last parameter, by reference. The file should be read until end of file has been reached or the array is full.
struct ship{
string shipCaptain;
string shipName;
};
The function prototype is
void readFile( ifstream&, ship[ ], int, int& );
ifstream - The already open file
ship[ ] - array of structs where the data from the file will be stored.
int - the size of the array.
int& - the number of records read from the file. This value is set by the function before returning
return- the number of records read from the file, returned by the function.
The amount of data in the file is unknown but there is no bad data. The file format is the shipsName followed by the shipsCaptiain .
Example:
MillenniumFalcon HansSolo
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images