I'm trying to make a simple code, but std::cin is being skipped

Hello there!
I’m starting to learn how to code, and based on the lesson about “vectors”, I made this simple code.
The problem is that the Codecademy workspace is skipping my std::cin and is just printing everything at once. How can I fix this?
I’m also accepting feedback!

This is my code:

#include <iostream>
#include <vector>

int main() {
  int even = 0;
  int odd = 1;
int input;

std::vector<int> numbers;

for (int o = 5; o > numbers.size(); o--){
std::cout << "Please input " << o << " more numbers\n";
std::cin >> input;
numbers.push_back(input);
}

for (int i = 0; i < numbers.size(); i++) {

  if (numbers[i] % 2 == 0) {
    even = even + numbers[i];
  }
  else {
    odd = odd * numbers[i];
  }
}

std::cout << "The sum of all even numbers is " << even << "\n";
std::cout << "The product of all odd numbers is " << odd << "\n";


}

I have the same issue. Let me know if someone answers. It would be very useful.

It’s a slippery slope to change the size of your container you are iterating on as you iterate on it.

As for the platform bypassing your std::cin… as a sanity check try it outside a loop, then try it in a more normal loop

for example

for (int i = 0; i < 2; i++)

to isolate whether it’s your loop itself or the platform.

Of course the best thing is to just run it locally on your computer, this is C++ so the quicker you get used to compiling locally the better.