With this code I am trying to build an array with integer values entered by the user. the variable "int selection" is an int, so if the value entered is an int, the while loop should keep going, but the value 0 seems to end it and I can't figure out why. Thank you for your help guys.
int main()
{
//data to be entered
int selection;
//array size
int const array_size = 100;
//array
int integers[array_size];
//array index
int index = 0;
//prompt
std::cout << "Enter integer ('x' to quit): " << std::endl;
//get the data
std::cin >> selection;
//while data is int
while (selection)
{
//put it in the array
integers[index] = selection;
//increment index
index += 1;
//get new data point
std::cin >> selection;
}
return 0;
}