Memory Management in C
Puneet Saini, Ria Arora
C , Language , Memory Management , malloc , Calloc
Manual memory management for dynamic memory allocation in the C programming language is what is referred to as dynamic memory allocation. There are two ways of allocating memory allocated in C, ie, by declaring the variables and by explicitly requesting space. We have discussed variable declaration in other lectures, but here we will describe requesting dynamic memory allocation and memory management. Space is allocated for a pointer by C whenever a pointer is declared. For example: char *p; Four consecutive bytes in memory are allocated which are associated with the variable p. Pointer to char is declared to be the type of pointer p. However, initialization of memory location does not happen, so it may contain garbage.Initialising the pointer at the time it is declared is usually a good idea. Its function is to reduce the chances of a random value in p to be used as a memory address. A pointer must be pointing to a valid area of memory before we can actually use it. The function malloc is used to request a pointer to a block of memory and calloc is used to request an array of zero-value initialized blocks.
Article Details
Unique Paper ID: 142754

Publication Volume & Issue: Volume 2, Issue 6

Page(s): 257 - 258
Article Preview & Download

Share This Article

Join our RMS

Conference Alert

NCSEM 2024

National Conference on Sustainable Engineering and Management - 2024

Last Date: 15th March 2024

Call For Paper

Volume 11 Issue 1

Last Date for paper submitting for Latest Issue is 25 June 2024

About Us enables door in research by providing high quality research articles in open access market.

Send us any query related to your research on

Social Media

Google Verified Reviews