my vector is not recording any data from my text file
the text file contains 106,187 words but for testing purposes i'm using the below set:
The text file format
bleeping
damned.
adj
blemishless
Without blemish; spotless.
adj
blendous
Pertaining to consisting of or containing blende.
adj
abaca
The Manila-hemp plant (Musa textilis); also its fiber. See Manila hemp under Manila.
n
abacinate
To blind by a red-hot metal plate held before the eyes.
v
abacination
The act of abacinating.
n
i need to get the words into the words vector and definitions into the definitions vector and then the types into the types vector. afterwards i need to search for a word and be able to get the meaning and the type. for this i was thinking of using a for loop would that be a good idea or is there any other way.
My Code
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
class Files {
private:
string word;
string definition;
string type;
string blank;
vector<string>words;
vector<string>definitions;
vector<string>types;
public:
void read();
//void intro();
void display(vector <string>& words);
};
void Files::display(vector <string> & words) {
std::cout << "The vector elements are : ";
for (int i = 0; i < words.size(); i++)
cout <<"running"<< words.at(i) << ' ';
}
void Files::read()
{
Files d;
int i = 0;
string e, t;
ifstream out("Text.txt");
string array[]{ d.word,d.definition,d.type,d.blank };
vector<string>words;
do
{
(getline(out, d.word, '\n'));
words.push_back(word);
getline(out, d.definition, '\n');
definitions.push_back(definition);
getline(out, d.type, '\n');
types.push_back(type);
getline(out, d.blank, '\n');
i++;
cout << "number of line " << i << ' ' << d.word << endl;
} while (!out.eof());
display(words);
}
int main()
{
Files d;
//intro();
d.read();
//d.display();
}