Task: Functions and File I/O (1.0)
Define a structure Pet consist data fields: status (lost or found), pet type, gender, breeds, age of year, age of month, colour, chip number, location, contact phone number in a file pet.h.
Define functions’ prototypes and other necessary definitions in the file pet.h.
The data fields’ types are decided by you.
Implement a function countRecords(char *) in a file pet.cpp that can return how many records of pets in a given text file. Implement a function loadRecords(char *, Pet *, int) load the pet records in a dynamic Pet array from the given text file. Implement a function printRecords(Pet *, int) print out all the pet records.
The example file pets.dat of pet records can be downloaded from the site of the lab task.
Each record stored in one line, different data fields separated by commas except the last field. There might be some empty lines in a given text file. The empty lines cannot be count as the records.
Implement driver program in the main function in pet.cpp to get the input text file name from a user, print out number of pet records that stored in the file, load pet records and print out all the data that loaded.
Don’t forget to delete the dynamic pet record array before the program finished.