#include #include//this is the library where malloc,calloc, realloc, and free live int main(int argc, char *argv[]) { /*Static memory C declarations*/ //single variable int x; //hardcoded size 10 array int statarray[10]; //array of size n //int array[n]; //note, not possible to do array[n] (at least not in proper convention) //structure typedef struct test_{ int num; char name[50]; }test; //array of structures test new[10]; /*DMA style declarations*/ //single variable int * single; single = (int *)malloc(sizeof(int)); free(single); //hardcoded size 10 array int * dmarray; dmarray = (int *)malloc(sizeof(int)*10); //array size n int * narray; int n; printf("Enter size of array\n"); scanf("%d",&n); narray =(int*)malloc(sizeof(int)*n); if(narray) printf("Integer Array of Size %d Declared\n",n); else printf("Failed to Create Array of Size %d\n",n); //structure typedef struct{ int * pint; char * string; }DMA; DMA * mem;//pointer to a struct object mem = (DMA *)malloc(sizeof(DMA));//get memory for the struct mem->pint = (int *)malloc(sizeof(int));//get memory for the int *(mem).string = (char *)malloc(sizeof(char)*50);//get memory for the string //array of structures DMA * DMAstructs[10]; int i;//just a loop var for(i =0;i<10;i++) { DMAstructs[i] = (DMA *)malloc(sizeof(DMA)); DMAstructs[i]->pint = (int *)malloc(sizeof(int)); DMAstructs[i]->string = (char *)malloc(sizeof(char)*50); } }