+ 1

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.

18th Jan 2020, 3:19 PM
Leo Hunter
Leo Hunter - avatar
2 Réponses
+ 1
When you installed NetBeans did you install a c++ compiler? If you did check your compiler settings. Usually you get a similar error in CodeBlocks when the IDE cannot find your compiler.
19th Jan 2020, 3:10 PM
George Ryan
George Ryan - avatar
+ 1
Yes i did, i even try running hello world and it worked.
19th Jan 2020, 11:19 PM
Leo Hunter
Leo Hunter - avatar