初級 › int型のゼロ除算で実行時に落ちる原因 › パターン4
int型のゼロ除算で実行時に落ちる原因
int型同士の割り算で除数が0になったときに実行時エラーで異常終了するバグです。
1 #include <iostream> 2 int main() { 3 int budget = 500; 4 int teams = __; ^ 5 std::cout << (budget / teams) << std::endl; 6 return 0; 7 }
Floating point exception
空欄を埋めてコンパイル・実行を通す
int型の0除算はコンパイルも通ってしまい、実行時にプロセスごと強制終了します。
次の問題