1 example for malloc

{{ score }}
  # What it does?
# allocate dynamic memory for the requesting process

# What is the Signature?
# void* malloc(size_t size);

# Which library to include?
# stdlib

# What is the parameter taken?
# Number of bytes that the programmer wants.

# What is returned?
# If there is enough memory to allocate, the call will return a pointer to the allocated block, if not NULL is returned. If size is  0, then malloc returns either NULL, or a unique pointer value that can later be successfully passed to free.

# Others
#  Returned memory can contain Junk values, accessing them invokes undefined behavior.
# When you no longer need the memory, call free and pass the pointer which was returned by malloc.
# calloc does same thing as malloc expect that the memory is initialized with 0. 

# SAMPLE PROGRAM:

#include
int main()
{
    int *ptr_one;
    //allocate 
    ptr_one = (int *)malloc(sizeof(int));
    if (ptr_one == 0) {
        printf("ERROR: Out of memory\n");
        return -1;
    }
    
    //use
    *ptr_one = 25;
    printf("%d\n", *ptr_one);
 
    //free
    free(ptr_one);

    return 0;
}

your_command_here