Code Fix

初級Floating point exception(整数のゼロ除算) › パターン1

Floating point exception(整数のゼロ除算)

int型を0で割ったときに発生するクラッシュです。

 1  #include <stdio.h>
 2  
 3  int main(void) {
 4      int total = 10;
 5      int count = __;
                     ^
 6      printf("%d\n", total / count);
 7      return 0;
 8  }
Floating point exception

空欄を埋めてコンパイル・実行を通す

広告
広告スロット(未設定)

Floating point exception(整数のゼロ除算)

Cはこれを例外として捕まえられず、プログラムはその場で強制終了します。

このエラーの解説と類題をまとめて見る →

広告
広告スロット(未設定)