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
Can I initialize unions?
Can we access the array using a pointer in c language?
Are enumerations really portable?
What is LINKED LIST? How can you access the last element in a linked list?
What is the right way to use errno?
Difference between exit() and _exit() function?
Is struct oop?
Input is "rama loves rajesh and rajesh Loves rama also and rajesh wear gloves and bloves" To print output is count the numbers of times repeted the word love without case sensitive.
If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402
What does == mean in texting?
Explain the use of 'auto' keyword in c programming?
please give me a VIRTUSA sample palcement papers.... you will only send TECHNICAL SECTION..... that is help for me Advance Thanks........................
When is a void pointer used?
What is volatile keyword in c?
What is page thrashing?