/* A dynamically-allocated 1-D array */
#include <stdio.h>
#include <stdlib.h>
int
main (void)
{
double* array; //declare a pointer only
int i, size;
//ask user for size of array
printf ("How large do you want your array? ");
scanf ("%d", &size);
//allocate the array in the heap with calloc
array = (double *) calloc (size, sizeof(double));
//printing the array for verification. calloc initializes all cells to 0.
for (i = 0; i < size; ++i)
printf ("%6.2lf", array[i]);
//freeing the memory allocation
free (array);
return (0);
}