Filling a string array with lines from a text file

I'm making a small educational program for my university course and I have a text file that goes like this:

1
2
3
What is the function of a binary Adder?
What is the purpose of the stack?
What is the difference between DC and AC?


I need a string array to be filled so that each line goes into a new position (consecutive of each other)

Also, the text document will change in length as more questions are added and such. So far I haven't found any ways of doing that that facilitate all these things...
Last edited on
Doing this with STL it goes like this:

1
2
3
4
5
6
7
8
9
std::ifstream is(...); // needs file name
std::vector<std::string> line_vector;
while(is.good())
{
  std::string line;
  std::getline(is, line);
  if(is.good())
    line_vector.push_back(line);
}


This may give you an idea how to accomplish it
Topic archived. No new replies allowed.