disadvantages of realloc ?
Library:<stdlib.h>
define:void *realloc(void *ptr, size_t size);
it modifies the existing size of block to new size with
copies of existing data.simply it add/delete the memory of
existed pointer based on new size without changing its
contents and it returns the pointer of first location.
possible cases:
1.if size >0,ptr is not null->modify the ptr with new size
and return pointer of 1st location.
2.if size is 0,ptr is not null->it would not change the
size of pointer but delete the existing contents.
3.if size >0,ptr is null->create new ptr with that size and
return that new pointer.
4.if there is not enough space to rellocate ptr,then it
return null pointer with out changing the block of data.
case 2 and 4 are disadvantages,since orignial contents are
getting deleted and also if we trying to use null pointer
then it would crash the program.
| Is This Answer Correct ? | 3 Yes | 0 No |
Ow can I insert or delete a line (or record) in the middle of a file?
What is the symbol indicated the c-preprocessor?
What are global variables and how do you declare them?
print ur name 20,000 times without using inbuilt library functions like printf,scanf,gets,puts,getchar or putchar
can we declare a variable in different scopes with different data types? answer in detail
How does the assert() function work?
Reverse the part of the number which is present from position i to j. Print the new number. eg: num=789876 i=2 j=5 778986
Read two numbers from keyboard and find maximum of them?
write a programme to enter some number and find which number is maximum and which number is minimum from enterd numbers.
What is I ++ in c programming?
How do we print only part of a string in c?
main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }
5 Answers Vector, Vector Solutions,