Basically what the title says. I'm trying to write code that will take in a random word from a file called "words.txt" and output it. I run it and keep getting the error "Floating Point Exception (Core Dumped)".
Here's the code:
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <vector>
using namespace std;
int main ()
{
vector<string> word;
fstream file;
file.open("words.txt");
cout << word[rand()% word.size()]<<endl;
return 0;
}
And here's "words.txt"
duck
goose
red
green
phone
cool
beans
Thanks guys!