Question: 1) Where is the memory leak in this code? int main() { int *array; array=(int *)malloc(sizeof(int)*1000); for( i = 0; i < 1000; i++ )
1) Where is the memory leak in this code?
int main() { int *array; array=(int *)malloc(sizeof(int)*1000); for( i = 0; i < 1000; i++ ) array[i] = i; return 0; }
2) (a) Where is the memory leak in this code? (1 pt)
(b) How do you fix it? (2 pts)
int main() { int **array; array=(int **)malloc(sizeof(int *)*1000); for(i=0;i<1000;i++) array[i]=(int *)malloc(sizeof(int)*500); free(array); return 0; } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
