Currently learning C++ building a little program that takes in movie names, stores them in a vector and then outputs it based on user input. The problem is I made a function for displaying the movies list. Now every time I run that function I get this error:
Unhandled exception at 0x769DA842 in ConsoleApplication2.exe: Microsoft C++ exception: std::out_of_range at memory location 0x0113F674.
Here's the code:
#include <iostream>
#include <vector>
std::vector <std::string> movieList;
std::vector <int>::iterator it;
void AddMovie(std::string movie)
{
    movieList.push_back(movie);
}
void DeleteMovie(int i)
{
    movieList.erase(movieList.begin() + i - 1);
}
void ShowMovies()
{
    for (int i = 0; movieList.size() > 1; i++)
    {
        std::cout << movieList.at(i) << std::endl;
    }
}
int main()
{
    int i{ 0 };
    movieList.push_back("Inception");
    movieList.push_back("Peter Pan");
    movieList.push_back("Jaws");
    std::cout << "Delete movie: ";
    std::cin >> i;
    DeleteMovie(i);
    ShowMovies();
    
}
The error breaks at line
std::cout << movieList.at(i) << std::endl;
 
    