#include #include /* Test that memory is properly de-allocated by using valgrind to execture * * To compile: gcc lab4b.c * * To execute: ./a.out * * To execute with valgrind tool: valgrind ./a.out */ int main (int argc, char** argv) { int i; /* allocation and use of a dynamic ONE dimenstional array */ /* variable declararion */ int* arr1; /* allocate space for 20 intergers */ arr1 = (int*) malloc (sizeof(int) * 20 ); /* initialize all array locations to contain the value zero */ for ( i = 0 ; i < 20 ; i++ ) arr1[i] = 0; /* print out all of the values */ for ( i = 0 ; i < 20 ; i++ ) printf ("Position: %3d, value: %3d\n", i, arr1[i]); /* de-allocated the memory for the array when finished */ free (arr1); return 0; }