When I try to run this program, I get an error message that stops the program and says: "Vector index out of range"
Any idea what I'm doing wrong?
#include <vector> #include <string> #include <iostream> #include <iomanip> #include <fstream> #include <sstream> using namespace std; //(int argc, char* argv[] int main() { fstream bookread("test.txt"); vector<string> words; bookread.open("test.txt"); if(bookread.is_open()){ cout << "opening textfile"; while(bookread.good()){ string input; //getline(bookread, input); bookread>>input; //string cleanedWord=preprocess(input); //char first=cleanedWord[0]; //if(first<=*/ //cout << "getting words"; //getWords(words, input); } } cout << "all done"; words[0]; getchar(); }
c ++ file vector
charli
source share