Why doesn't my C++ code run in netbeans?
Hello everyone, I'm new to C++ and I'm having a problem with my code. Here it is: #include <iostream> #include <fstream> #include <cstring> #include <string> #include <cstdlib> #include <vector> using namespace std; //Returns a word from "wordList.txt" given the criteria of the parameters string generateWord(int lenOfGivenWord, string firstCharGuess){ ifstream wordlist; wordlist.open("wordList.txt"); string word = firstCharGuess; vector <string> words; //Checks to see if word (string) is of the same length and does not contain the first guess letter while(word.length() != lenOfGivenWord && word.find(firstCharGuess) != std::string::npos) { word = words[rand() % words.size()]; } wordlist.close(); return word; } int main () { generateWord(3,"d"); return 0; } What this function is doing is getting a random word from wordList.txt that has the length of 3 and does not have the letter 'd' in it. The code builds fine but i get the error message: RUN FAILED (exit value -1,073,741,511, total time: 205ms). The wordList.txt is in the same folder as generateWord but that doesn't seem to be the problem. Could you guys help me out? Every answer will be appreciated and thanks in advance.