cin
is working properly, of course. Your code , on the other hand, wrongly assumes that input operation was successfully completed. Try this fix:
#include <iostream>
using namespace std;
int main()
{
int num;
do
{
cout<<"sdjlsdklsdf";
cin >>num;
if (! cin.good()) break;
}while (num!=100);
return 0 ;
}