Instruction
For this project, read each line of the web log file as one string using the string class' getline function. Because this program needs to return any line requested by the user, you should put each line of the file into an array. It is much more efficient to read data from temporary memory than to read from the hard drive, so the objective is to only read from the file once. Once the data is loaded into the array, you can access the data in the array stored in memory as many times as the user needs it, without the significant overhead of reading from the file on the hard drive.
Minimum Requirements:
Create a function that performs these tasks:
Read each line of the web log file into the array. This function must do error checking to ensure that the file is opened successfully. Otherwise it must provide a message like "file not available" to the user. Each line should then be pulled from the file using getline and stored in a container such that the first element of the container is the first line of the web log file. Because each element will hold an entire line from the file, the container should be declared with a string data type. For your array, use size 2990.
Ask the user for a line number, and display that line from the array. Remember, the array indexes begin with 0, so if the user requests the first line, display the string in array position 0 (not position 1). You will need to do a little arithmetic to get the correct line to display. Put this in a loop so the user can request another line or quit.