debug assertion failed!

this program scans a text file to see if words exist in it. this is not the whole program, so the random characters are not relevant to the program yet, but the program searches a vector containing approximately 38,000 words, and if it is there, then it prints "Correct!". the program works, but at the end it says "debug assertion failed!
Expression: vector subscript out of range"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
 #include <fstream>
#include <iostream>
    #include <string>
    #include <vector>
#include <algorithm>
#include <ctime>
#include<windows.h>
#include<dos.h>
    using namespace std;
	 vector<string> words;

	 string word;
	 char randchars[6];

	 void load_file(){
	 ifstream file;

		file.open("");
		
		file.open ("c:\\TEXT TWIST\\words.txt");

		std::string word;
		if(file.is_open()){

while(file >> word)
{
    words.push_back(word);
	
}


		cout<<"@@@@MAIN@@@@@"<<endl;

		
		}

		else{
		cout<<"Unable to open file!"<<endl;
		}
	 }

		void rand_chars(){
		for(int i = 0;i <=6;i++)
		randchars[i] = rand() % 26 + 65;
		}

    int main()
    {

srand( time(0));

bool test;
		int it;
		load_file();
       rand_chars();
       string word_1; 

	  cout<<"Here is your set of words:";

	  for(int i = 0;i<=6;i++){
	  cout<<randchars[i];
	  }
	  cout<<endl;
	  cin>>word_1;
	  for(int i = 0;i <= words.size();i++){
		  if (word_1 ==  words[i]){
		  
		  cout<<"CORRECT!";
		  }
	  }
	  cout<<"MAIN";
		system("pause");
		return 0;
    }
In your for loops you make one iteration to much. You should replace <= with < in you loop conditions.
thank you so much!!!
Topic archived. No new replies allowed.