I created an array of user-defined size and trying to enter the values but when for-loop is executed it is only taking one value
#include<iostream>
#include<vector>
using namespace std;
int main()
{
int s;
cin>>s;
vector <int> arr;
int input;
for(int i=0;i<s;i++)
{cin>>input;
arr[i]=input;}
for(int i=0;i<s;i++)
cout<<" "<<arr[i];
}
my input
5
1 2
expected input
5
1 2 3 4 5
output
program crashed after entering the value 1
expected output
1 2 3 4 5