How to read file data in storage.

I am trying to read a config file into a block of storage. How do create a block of storage, like an array of pointers, what would that look like? and how do you get ifstream to send the data to that block?

here's a snippet of my code:


fileIn.open(filename.c_str()); // Opens file for reading

while (!fileIn.eof())
{
fileIn.getline(line, MAX_COMMENTS); // Reads file line by line
if (line[0] == '#') // Searches for comments
{
fileIn >> comments; // Sends comments to string comments
}
while (!fileIn.eof()) // Reads file as long it is not the end
fileIn.getline(line, LENGTH);

I am asking what should go here.

And also, how to create an array of pointers(or some type block of storage) for about 15 lines from a config file.
Last edited on
Just use a vector of strings, so you do not have to manage to size.

Btw, stuff like fileIn >> comments; won't work if comments is a string, you will probably want to either make it a file or an fstream.
Last edited on
Topic archived. No new replies allowed.