Pointer initialisation gives segmentation fault

后端 未结 5 650
刺人心
刺人心 2020-12-03 04:09

I wrote a C program as follows:

CASE 1

int *a; /* pointer variable declaration */

int b; /* actual variable declaration */

*a=11;

a=&b;/* st         


        
5条回答
  •  盖世英雄少女心
    2020-12-03 04:17

    int a stores a random integer value. So saying by saying *a, you might be accessing a memory location that is out of bounds or invalid. So it is a seg fault.

提交回复
热议问题