草庐IT

IOStream

全部标签

关于 c :Catch cin 异常

Catchcinexception我想询问用户输入,我用cin得到这样的输入voidAskForGroundstate(){  cout"PleaseenterangroundstatepotentialvalueinVolt:"endl;  if(!(cin>>_VGroundstate)){    cin.clear();    cin.ignore();    cout"Groundstatepotentialnotvalid."endl;    AskForGroundstate();  }}_VGroundstate是一个双精度值,所以如果用户输入一个没有数字的字符串,它应该再次要求