/* File: allocate.c This file demonstrates memory allocation. */ #include #include "genlib.h" #include "simpio.h" /* On some systems you should include the following */ #include main() { char *letters, c ; int i ; /* get a block of memory with 26 bytes */ letters = malloc(26) ; /* Lets use it as an array */ i = 0 ; c = 'a' ; while (c <= 'z') { letters[i] = c ; c++ ; i++ ; } /* print out the characters */ for (i = 0 ; i < 26 ; i++) { printf("%c", letters[i]) ; } printf("\n") ; /* Give up use of the memory block */ free(letters) ; }