Can't find the error!

My professor has written this code on the board and everyone was able to run it but me. When I use Visual Studio it gives me this error:
"Unhandled exception at 0x774E5B68 in Working with Strings.exe: Microsoft C++ exception: std::out_of_range at memory location 0x005FFA24."

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
#include <iostream>
#include <string>
using namespace std;

int main()
{
	string str = "counting the number of vowels";
	int i;
	int numchars;
	int vowelcount = 0;

	cout << "The String: " << str << endl;

	numchars = int(str.length());

	for (i = 0; i <= numchars; i++)
	{
		switch (str.at(i))
		{
		case 'a':
		case 'e':
		case 'i':
		case 'o':
		case 'u':
			vowelcount = vowelcount + 1;
		}
	}
	cout << "The String has: " << vowelcount << "vowels." << endl;

	system("pause");
	return 0;
}
i have the same problem, please help me solver
Topic archived. No new replies allowed.