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
Explain how do you sort filenames in a directory?
simple program of graphics and their output display
What is this infamous null pointer, anyway?
Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.
How can you avoid including a header more than once?
What do header files do?
Why are algorithms important in c program?
What is a node in c?
What is the difference between declaring a variable and defining a variable?
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
What is pointer in c?
GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)
how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?
What are qualifiers?
How can this be legal c?