I know that this is a common question but i could not find any solution to this question without using vectors and ctrl + d/c. I have encounter a infinite while loop while using cin to get a unknown amount of integer. the while loop does not stop executing even after a enter in pressed. Thanks a lot!
while(cin >> num)
{
num--;
sizeB = 0;
setB[sizeB] = num;
sizeB++;
}
cin.ignore();
cin.clear();
getlineinstead? - Zetanumis an integer than typing letters and pressing Enter will cause the loop to exit - M.Mcin. (operator>>returns reference tocin). It's equivalent to doing!cin.fail(), i.e. check that neither end-of-file occurred, nor that something was typed which failed to be converted to the type ofnum. - M.M'does not return the same as member good, but the opposite of member fail'- Marco A.