Question: In C language, Describe the problem AND the solution for each of the following code fragments that compiles successfully, but creates a runtime error. (There

In C language,

In C language, Describe the problem AND the solution for each of

the following code fragments that compiles successfully, but creates a runtime error.

Describe the problem AND the solution for each of the following code fragments that compiles successfully, but creates a runtime error. (There is only one problem per fragment) a void main(void) { int iVal = 10; int *iPtr = iVal; printf("%d == %d", iVal, *iPtr): } b void main(void) { char * cPtr = (char*) malloc(3 *sizeof(char)); int * iPtr = (int *) cPtr; *iPtr = 2; printf("%d", *iPtr); /Assume memory is properly freed after this } void main(void) { int *iVal = NULL; int *iPtr=iVal; scanf("%d", iPtr): printf("%d", *iPtr): } d int * foo { int iVal; scanf("%d", &iVal): return &iVal; } I/Assume foo is called from main() void main(void) { int *iPtr = (int *) malloc(sizeof(int)); int *iPtr2 = iPtr free(iPtr); printf("%d", *iPtr2); e

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!