Files
Linux_C/02-segfault/segfault.c
2024-10-10 23:21:21 +08:00

7 lines
186 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
int main() {
int *ptr = NULL; // 初始化一个指向NULL的指针
*ptr = 1; // 尝试写入NULL指针引用的地址这将导致段错误
return 0;
}