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
a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f
I have seen function declarations that look like this
How can I ensure that integer arithmetic doesnt overflow?
Explain what is the difference between functions getch() and getche()?
Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;
Which is an example of a structural homology?
Why malloc is faster than calloc?
Write a code to generate divisors of an integer?
Why static variable is used in c?
What is a struct c#?
Difference between macros and inline functions? Can a function be forced as inline?
What is atoi and atof in c?
Should a function contain a return statement if it does not return a value?
Write a program that accept anumber in words
How can I rethow can I return a sequence of random numbers which dont repeat at all?