Question: 4. In the following code, the first printf() reached produces the output 14, but the second printf() can cause a bus error or a
4. In the following code, the first printf() reached produces the output 14, but the second printf() can cause a bus error or a segmentation fault. Why? main () { int *p; funct (p); printf("%d ", *p); } funct(int *p2) { p2=(int *) malloc (4); *p2=14; printf("%d ", *p2); }
Step by Step Solution
3.46 Rating (159 Votes )
There are 3 Steps involved in it
The code snippet you provided is an example of improper use of pointers in the C programming language which can lead to undefined behavior including b... View full answer
Get step-by-step solutions from verified subject matter experts
