Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - malloc http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   malloc

   Usage
   #include <stdlib.h>
   void *malloc(size_t numbytes);

   Description
   malloc  allocates  a  block of memory that is  numbytes  in  size.  If
   numbytes is 0, NULL is returned.

   Example
   #include <stdlib.h>
   #include <stdio.h>
   #define NUM_INTS 7623
   int *memblock;
   main()
   {
        memblock = malloc(NUM_INTS*sizeof(int));
        if(memblock == NULL)
             printf("Insufficient memory\n");
        else
             printf("Memory allocated\n");
        free(memblock);
   }

   Return Value
   Pointer to the memory block allocated. NULL is returned if not  enough
   memory is available, or if numbytes is 0.


See Also: calloc free realloc farmalloc

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson