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
Write a C program in Fibonacci series.
What is include directive in c?
What is dynamic dispatch in c++?
What is the benefit of using #define to declare a constant?
What is c mainly used for?
What are the different types of errors?
Explain the difference between malloc() and calloc() function?
Where we use clrscr in c?
process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,
What is a constant and types of constants in c?
How do I swap bytes?
What does main () mean in c?
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.
What is pointer to pointer in c language?
What are the difference between a free-standing and a hosted environment?