Answer Posted / vignesh1988i
malloc is briefly termed as Memory ALLOCation ......
whenever we write a program in C we will declare some
variables or arrays for a size more than whatever we need ,
etc etc..... so some variables are getting used correctly
and in arrays only some of the memory spaces are getting
used because the user dont know how much spaces he is gonna
use.......so here some memory is getting wasted without
using it.... so there comes a concept called DYNAMIC MEMORY
ALLOCATION in C...
we will give the values for how much memory we need at the
run time of the program... but this concept also only 85%
efficient... this has three types :
1)malloc();
2)calloc();
3)realloc();
malloc() is a function present in ALLOC.H standard library
which is used to allocate memory at run time (ie) in single
or in blocks.....
the syntax is :
pointer_variable=(typecasting
datatype*)malloc(sizeof(datatype));
this pointer variable should be of same datatype as the
typecasting datatype........
thank u
| Is This Answer Correct ? | 4 Yes | 2 No |
Post New Answer View All Answers
What are the functions to open and close file in c language?
Explain what is the difference between far and near ?
Explain how can I write functions that take a variable number of arguments?
What is #define used for in c?
Write a code on reverse string and its complexity.
I need testPalindrome and removeSpace
#include
how many key words availabel in c a) 28 b) 31 c) 32
I came across some code that puts a (void) cast before each call to printf. Why?
GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA
What is pivot in c?
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion
Why is extern used in c?
Write the test cases for checking a variable having value in range -10.0 to +10.0?
Do you know the purpose of 'register' keyword?
How can I do peek and poke in c?