malloc() attempts to retrieve designated memory segments from the heap and returns a pointer for the memory reserved. - C Memory

C examples for Memory:malloc

Introduction

The malloc() function is part of the standard library <stdlib.h> and takes a number as an argument.

Basic malloc() use is demonstrated in the next program.

Demo Code

#include <stdio.h> 
#include <stdlib.h> 
int main()/*from ww  w  . j a v a2 s .  co m*/
{ 
   char *name; 
   name = (char *)malloc(80); 
}

Related Tutorials