Your loop never stops because you increment i after you get your input. You are always comparing the next array element after the one receiving the input.
That potentially can lead to undefined behavior after going out of bounds on your array.
PLEASE learn to use code tags, they make reading and commenting on source code MUCH easier.
That is because you have increased "i" by 1. The while condition is checking the next element in the array, which probably a garbage value, and although that garbage value is likely a negative number it is not (-999).
The (-999) you are looking for is actually at (i - 1), but changing the while condition to (i - 1) will not work either.
while (storeArray[i] != -999)
{
// <--- Needs a prompt. Unless you like staring at a blank screen.
std::cin >> storeArray[i];
if (storeArray[i] != -999)
{
i++;
validEntries++; // <--- How do you know it is valid and what do you consider valid?
totalEntries++;
}
}
//storeArray[i] = 0; // <--- If you do not want (-999) in the last element, but then "i" is 1 more than it should be.
I do not claim it is the best way or only way, but it does work.
const std::string PROMPT{ " Enter a number (-999 to quit): " }; // <--- Change as to you like.
while (std::cout << PROMPT && std::cin >> storeArray[i] && storeArray[i] != -999)
{
i++;
validEntries++; // <--- How do you know it is valid and what do you consider valid?
totalEntries++;
}