So in my vector string, my program is reading in the line texts from a Constitution text file, and although it is successfully reading in each line, I am unsure how to separate each line with an end line. For instance, the first line is the Preamble, then under the preamble the text starting with "We the the people.." should be located, however it continues on the same line as Preamble.
// create function to read in constitution file and also implement reading each line in file
// implement vectors and strings for storing words
//Step 1) be able to read in a line and have an option exit program:
void ReadtheFile(vector<string> &Constitution , int &lineNumber){
// open the file
// line number increases each time there is a line that isn't equal to a space
// create a vector string that inputs all of the lines from constitution text file
ifstream InfileStream;
string fileText = "ConstitutionAndBillOfRights.txt";
string inputLine;
InfileStream.open(fileText.c_str());
// verify that file is open
if(!InfileStream.is_open()){
cout << "Could not find Constitution text" << endl;
exit(-1);
}
// input lines from file
while(getline(InfileStream, inputLine)){
//store lines into Constitution vector
if(inputLine.length() == 0 || inputLine[ 0] == ' '){
continue;
}
int Size = inputLine.size();
if(inputLine.length() > 1){
Constitution.push_back(inputLine);
lineNumber++; // line number for Constitution Text
}
}
InfileStream.close();
//cout << Constitution.at(1); // checking that vector stores in each line correctly
}// end ReadtheFile)