Programming_cin - アールメカブ

アールメカブ


Programming_cin

Programming

int は 2147483647 までで,これを超えるとオーバーフローする.ループ処理の中でうっかりオーバーフローを起こすと,無限ループになりかねない.

対処療法はこう.

 int kokugo = 0 ;
 cout << "国語の点数を入力してください。" << endl ;
 cin >> kokugo ;

 if(cin.fail()){
  cout << "Error" << endl;
  return 1;
}
 
Link: Programming(4978d) Programming_C(5429d) 日録2007_10月(6005d)
Last-modified: 2007-10-18 (木) 15:54:10 (6028d)