How to have c++ pause to wait for user input in for loop
I have the following code snippet in c++
int main(){
std::vector<int> numbers(10);
for (int i = 0; i < numbers.size(); i++){
std::cout << "Please enter number " << i << "\n";
std::cin >> numbers[i];
}
}
My hope is that for every value of i in the for loop, then code would wait for my input to enter the next number. However, instead I just get "Please enter number i" printed out 10 times, and the loop ends. I'm fairly new to c++ so I'm not too sure how to work around this, and moreover why my code is wrong.
from Recent Questions - Stack Overflow https://ift.tt/2RRDTkd
https://ift.tt/eA8V8J
Comments
Post a Comment