Beginner here so please be patient. I am having a bit of a trouble using a list of words for a simple hangman program that I am creating as an exercise. I am using this code to read a list of words from a text file:
vector<string> getWords()
{
vector<string> text_file;
ifstream ifs( "my_hangman_words.txt" );
string temp;
while(getline(ifs, temp))
{
text_file.push_back( temp );
};
return text_file;
}
This works fine when I compile and run directly but then it does not when I run the executable individually. From what I understand I need to write the vector to a file and #include the file with my program. Could someone give me a pointer on how to achieve that?