pointer_variable=(typecasting
datatype*)malloc(sizeof(datatype));
This is the syntax for malloc?Please explain this,how it
work with an example?
Answer Posted / pramod
I'll add few more lines to answer above just to make it a
bit more understandable.
Malloc allocates consequetive blocks of memory of requested
size.Then it returns the starting address of this block ,
the address returned is of type void , since it is a void
pointer so we need to typecast it to one that we requested
so typecasting is done( This headache has been removed in
C++ by using new as new automatically does this typecasting)
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
why wipro wase
How do you define structure?
How do I use strcmp?
Why is void main used?
What is pre-emptive data structure and explain it with example?
Why do we use static in c?
What is a memory leak? How to avoid it?
What is equivalent to ++i+++j?
Give the rules for variable declaration?
Explain how are 16- and 32-bit numbers stored?
What is the meaning of c in c language?
In C language, a variable name cannot contain?
What are the advantages of the functions?
Explain threaded binary trees?
What is the use of ?: Operator?