If cin expects a number but is given something else, it switches into an error state. Any following input statements will fail without managing to consume any of the input, unless you correct the situation.

So in the general case
Code:
int x=0;
  while(x!=6)
  {
   cout<<"in the loop"<<endl;
   if (!(cin>>x)) {
      cin.clear(); //reset the error state
      cin.ignore(1000, '\n'); //discard unsuitable input (just assuming they didn't type more than 1000 characters, consult FAQs for more correct ways)
   }
    
  }