I'm sorry if this question is stupid, but it's been kind of bugging me. I have written a program that is supposed to accept user input 5 times and then print out the result each time (i am using a while loop.) Here is the code I wrote:
#include <iostream>
int main()
{
int x = 1;
int number;
while (x <= 5)
{
std::cin >> number;
std::cout << number << std::endl;
x++;
}
return 0;
}
However, after compiling and running (i'm using clang) the program only lets me insert user input once and then it just prints a bunch of 0's:
jakdfjaksdfjk
0
0
0
0
0
I am really confused why this behavior happens. Shouldn't you be able to pass in user input 5 times? Why does this behavior happen? Help would really be appreciated.