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 an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.
What does static variable mean in c?
What are different types of operators?
What are Macros? What are its advantages and disadvantages?
Where is c used?
How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?
What is the main difference between calloc () and malloc ()?
Explain how can you determine the size of an allocated portion of memory?
Is it better to bitshift a value than to multiply by 2?
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.
Explain what is wrong with this statement? Myname = ?robin?;
Which function in C can be used to append a string to another string?
What should malloc() do?
What does %c mean in c?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?