The file downloads of an Internet service provider contain the following information for each upload at each line:
- IP client address (four integer values, 1-255)
- Upload status (0 = successful, 1 = unsuccessful, 2 = hold, positive integer with values of 0,1,2)
- File size in Mb (positive number, float)
- Transmission volume in Mb
The file is serial, given, and is named IP_clients.txt. Some lines of the file are:
191 255 244 1 0 15.7 15.7
198 168 2 3 2 23.0 16.0
Each IP address can be more than one time in the file.
Define a structure named log_client to manage this data. The members of the structure will be this information. Then define a table of structures of type log_client, N-places (N = known). The data in the table of structures will be imported by accessing the serial file IP_clients.txt. Assume that the value of N exceeds the number of records in the file. The following are requested (main () function:
- Import the data from the IP_clients.txt file into the table of structures by checking the existence of the file (see the code below) according to the above limitation. Find and display the number of lines in the file that the structure table will contain.
- Using all elements of the table of structures:
- Find the total volume and number of downloads in standby
- Enter a client's IP address from the keyboard without validating values, and then find and display for this client (if present in the table):
The total volume of successful and unsuccessful uploads, i.e. two separate values.