Question: Consider the following 3 code fragments: 1) int *ptr = malloc (sizeof(int)*3); ptr[0] = 0; ptr[1] 0; ptr[2] 0; 2) int ptr - calloc
Consider the following 3 code fragments: 1) int *ptr = malloc (sizeof(int)*3); ptr[0] = 0; ptr[1] 0; ptr[2] " 0; 2) int ptr - calloc (3, sizeof (int)) if (ptr== NULL){ printf ("Unable to allocate memory. In") exit (1): 3) int iptr= calloc ( 1 , sizeof (int)); if (ptr-NULL) { printf("Unable to allocate memory.In") exit (1) ptr realloc (ptr, 3 sizeof (int)) if (ptrNULL) printf("Unable to allocate memory.In") exit (1) Dynamic allocation of an integer array of size 3 with elements initialized to O is safely done in code fragment(s)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
