Ошибка индекса вектора вне допустимого диапазона, C ++

Когда я пытаюсь запустить эту программу, я получаю сообщение об ошибке, которое останавливает программу и говорит: «Векторный индекс вне допустимого диапазона»

Есть идеи, что я делаю не так?

#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();
}
6
задан Gregor Brandt 1 March 2011 в 23:30
поделиться