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++ 3.0r4 - <b>malloc</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
malloc

Usage

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

   ANSI

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 main()
   {
   int *memblock;

       memblock = malloc(NUM_INTS*sizeof(int));
       if(memblock == NULL) {
           printf("Insufficient memory\n");
           return EXIT_FAILURE;
       }
       else
           printf("Memory allocated\n");
       free(memblock);
       return EXIT_SUCCESS;
   }

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



See Also: calloc free realloc farmalloc

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