we have to use realloc only after malloc or calloc ? or we
can use initially with out depending on whether we are
using malloc or calloc in our program ?
Answer Posted / vadivel t
Hi Vignesh,
Ur explanation about realloc() is correct. But the answer
is wrong. Because, it is possible to use realloc() before
using malloc() or calloc() function be used.
Lets, try the below code.
int *ptr;
ptr = (int *)realloc(NULL, 5);
printf("%d \n", ptr);
In this code, realloc will allocate five bytes of memory
and will return a valid pointer. It can be used in ur
program.
Conclusion:
It simple means that, if u pass a NULL pointer to a realloc
() function, it will exactly behave as like malloc().
Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
what is the structure pointer?
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
How can I direct output to the printer?
How can I get back to the interactive keyboard if stdin is redirected?
The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?
the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters
What are data types in c language?
Explain the difference between #include "..." And #include <...> In c?
What does the file stdio.h contain?
difference between Low, Middle, High Level languages in c ?
What is the maximum length of an identifier?
Is c still used?
what is uses of .net
How arrays can be passed to a user defined function
Explain what are compound statements?