Arrays, Strings, and getline(). Help!

HELP!!!! I can't figure this out :(
You must use an array (not a vector).

Create a function to read each line of the web log file. Each line should then be stored in an array (not a vector) such that the first element of the array is the first line of the web log file. Because each element will hold an entire line from the file, the array should be declared as an array of strings.

Create a function that will ask the user for a specific line and then displays that line from the array. For example, if a user asks for line 1, the first element of the array should be displayed to the monitor. If a user enters a number less than 0 or greater than the size of the array, a message should display indicating that the number is not valid.

Create a function to write the first 50 elements of the array to an output file. Each element of the array should be on its own line in the new file. The entire contents of the new file should look like the first 50 lines of the input file

Create a main function that calls all of your functions.
What are you stuck on?
What do you have so far?
I'm stuck on how to create the array and make it so that it will store each line of the web log file.

Here's what I have so far:

#include <iostream>
#include <fstream>

using namespace std;

class Web
{
public:
void LogFileFunction(); //reads each line of web log file
array [50];
}
array is not a data type (unless you include <array>), and you need to give it a name.

Are you supposed to be using C strings or C++ strings?
C++
I only have until midnight to finish this program and I have two finals tomorrow so I've been running around with my head cut off like a chicken lol I can't keep anything straight in my head and I'm so bad at programming :/
Well.
Create a function to read each line of the web log file.
std::getline should help you with that.
http://www.cplusplus.com/reference/string/string/getline/
You can open a file using an std::ifstream object and then pass that as the first parameter for the std::getline function to read a line off of the file.
Combine that with a loop and an array and you should be able to read all of the lines (or at least the first 50, as is required by the assignment).

Each line should then be stored in an array (not a vector) such that the first element of the array is the first line of the web log file. Because each element will hold an entire line from the file, the array should be declared as an array of strings.
std::string myArrayName[50];

Create a function that will ask the user for a specific line and then displays that line from the array. For example, if a user asks for line 1, the first element of the array should be displayed to the monitor. If a user enters a number less than 0 or greater than the size of the array, a message should display indicating that the number is not valid.
Should be fairly straightforward.
Remember that array indices start at 0, not 1.

Create a function to write the first 50 elements of the array to an output file. Each element of the array should be on its own line in the new file. The entire contents of the new file should look like the first 50 lines of the input file
std::ofstream can be used to write to a file.
Topic archived. No new replies allowed.