日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

3 Segmentation fault (core dumped) ./a.out Exited with error status 139的決解辦法

作者:Austinu 更新時間: 2022-03-15 編程語言

出現錯誤的原因是空指針

通過以下實例說明

#include <stdlib.h>	
#include<stdio.h>
	int main()
	{
	    int *m;     //默認初始化為NULL
	    printf("It' OK here.\n");
	    printf("*m = %d\n",*m);   //使用NULL指針導致segmentation fault.
	    printf("Is here OK?\n");
	    return 0;
	}

運行結果:
在這里插入圖片描述

決解辦法:分配內存

int *m = (int *)malloc(sizeof(int))

運行結果:
在這里插入圖片描述

原文鏈接:https://blog.csdn.net/Austin_/article/details/108922880

欄目分類
最近更新