初級 › Segmentation fault(NULLポインタの参照) › パターン5
Segmentation fault(NULLポインタの参照)
NULL(何も指していないポインタ)の指す先を読み書きしようとしたときに発生するクラッシュです。
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main(void) { 5 int *count = ___________________; ^ 6 *count = 10; 7 printf("%d\n", *count); 8 return 0; 9 }
Segmentation fault
空欄を埋めてコンパイル・実行を通す
書き込み先がNULLのままだと、代入しようとした瞬間にクラッシュします。
次の問題