Skip to main content

DYNAMIC MEMORY ALLOCATION

THE PROCESS OF ALLOCATING THE MEMORY AT RUNTIME IS CALLED DYNAMIC MEMORY ALLOCATION . LIBRARY ROUTIEN KNOWN AS MEMORY MANAGEMENT FUNCTION ARE USED FOR ALLOCATING AND FREEING THE MEMORY DURING EXECUTION OF PROGRAM . THESE FUNCTINS IS DEFINE IN 'stdlib.h' HEADER FILE .


ALLOCATING BLOCK OF MEMORY -


1.) Malloc():-

                MALLOC()  IS A FUNCTION WHICH IS USED FOR ALLOCATING THE BLOCK OF MEMORY AT RUNTIME . THIS FUNCTION RESERVES BLOCK OF MEMORY AT  GIVEN SIZE AND RETURN A POINTER AS TYPE OF VOID . IF IT IS FAIL TO ALLOCATE ENOUGH SPACE AS SPECIFIED , IT RETURNS NULL POINTER . 

Syntax- void*malloc(byte-size) .

2.) Calloc():-

             Calloc() IS A FUNCTION WHICH IS USED FOR ALLOCATING AT RUNTIME  . CALLOC() FUNCTION IS USED FOR ALLOCATING MEMORY TO DERIVED DATA TYPE SUCH AS ARRAYS AND STRUCTURE . IF IT FAILS TO ALLOCATE ENOUGH SPACE AS SPECIFIED IT RETURNS NULL POINTER .

Syntax- void*calloc(no. of items, element-size).

3.) Realloc():-

                 realloc() CHANGES MEMORY SIZE THAT IS ALLOCATED DYNAMICALLY TO A VARIABLE .

Syntax - void*realloc(pointer , new-size) .

4.) Cfree():-

             DYNAMICALLY ALLOCATED MEMORY CREATED WITH EITHER calloc() OR malloc() DOES'NT GET FREED ON THEIR OWN . YOU MUST EXPLICITILY USE cfree() TO RELEASE THE SPACE .

Syntax- free(ptr);

-------------------------------------------------------------------------------------------------------------------------------

FOR MORE KNOWLEDGE CLICK BELOW   ⬇️

*C TOKENS

*SECONDARY DATA TYPES

*PRIMARY DATA TYPES

*CALLING FUNCTIONS

*C FUNCTIONS

*OPERATORS

Comments

Popular posts from this blog

BEST GAMING LAPTOPS FOR HIGH QUALITY/GRAPHICS GAMES

THE BEST GAMING LAPTOPS  NOW-A-DAYS THE TREND OF VIDEO GAMES HAS INCREASED. NEW GENERATION IS ENJOYING VIDEO GAMES VERY MUCH NOW-A-DAYS . MOST OF THE LATEST GAMES ARE COMING UP NOWDAYS WHICH ARE NOT ONLY APPEALING TO CHILDREN BUT  ALSO THE BIG ONES . AND NOWDAYS, GAMES THAT ARE BEING MADE A VERY HIGH QUALITY AND HIGH GRAPHICS IF YOU PLAY SUCH HIGH GRAPHICS GAMES IN A NORMAL LAPTOP THEN THE LAPTOP WILL TURN SLOWER AND HANG IT . THAT'S WHY THERE ARE DIFFERENT GAMING LAPTOPS   COMING FROM SUCH HIGH QUALITY GAMES THAT MUST BE READ BELOW . THE BEST GAMING LA PTO PS ARE FAST CHANGING IN 2019. NOW THAT THE  NEW 20-SERIES GPUs HAVE ST ARTED TO  FILTER INTO OUR FAVOURITE GAMING LAPTOPS MODEL , THE BALANCE OF WHICH ONE IS TRULY   'BEST' IS SHIFTING. WHILE, DOUBT THE BEST GAMING LAPTOP OF LAST YEAR WAS THE MSI GS65 STEALTH THIN , THAT SIMPLY ISN'T IN THE CASE AS WE GET MID-WAY THROUGH 2019. NOW, OUR BEST GAMING LAPTOP IS THE  RAZER BLADE...

How to Make a Bootable Pen drive: A Step-by-Step Guide

  How to Make a Bootable Pen drive: A Step-by-Step Guide   Introduction: In today's digital world, bootable pen drives have become indispensable tools for installing operating systems, running diagnostics, and recovering data. Creating a bootable pen drive is easier than you might think, and this guide will walk you through the process in a simple and straightforward manner. Whether you're a beginner or an experienced computer user, this step-by-step tutorial will help you create your own bootable pen drive effortlessly. Step 1 : Gather the Required Materials To make a bootable pen drive, you'll need the following items: 1. A USB pen drive with sufficient storage capacity (at least 8GB is recommended). 2. The ISO file or installation media of the operating system or tool you want to make bootable (e.g., Windows, Linux, etc.). 3. A computer with an available USB port. Step 2: Download the Required Software To create a bootable pen drive, you'll need specialized software...

Top 6 Best Video Games for 2GB RAM Laptops

Top 6 Best Video Games for 2GB RAM: Game Configurations and Recommended Laptops Introduction: When it comes to gaming, having a high-end gaming rig is often considered essential. However, not everyone has access to a powerful computer with loads of RAM and a dedicated graphics card. But fear not, as there are still plenty of enjoyable gaming experiences available for those with more modest hardware configurations. In this blog post, we will explore the top six best video games that can run smoothly on a system with 2GB RAM. Additionally, we will suggest some good laptops that are suitable for gaming on such specifications. 1. Star dew Valley: - RAM Requirement: 2GB - CPU: 2.00 GHz processor - GPU: Integrated graphics with 256MB video memory Star dew Valley is a relaxing farming simulation game that has captivated players with its charming visuals and engaging gameplay. With its low system requirements, it can run smoothly on systems with 2GB RAM. Download Here:  Star dew valley 2....