What is a memory leak in structures? How can we rectify that?
Answers were Sorted based on User's Feedback
Answer / selvaraj
unwanted memory consumed by a program is called memory leak.
Example:
int fact(void)
{
size=melloc(20);
if(size==NULL)
{
return 1;
}
else
{
return 0;
}
}
Explanation:
size=melloc(20);
here the memory reserved
if(size==NULL)
if memory not available
else means memory available return 0
so, throughout the program the size never used but the program reserved the size. this is called memory leak..
to over come this problem in the else part before return 0; add this statement free(s)
Hope you understood. if not u can reach me iamselvam85@gmail.com
Is This Answer Correct ? | 13 Yes | 2 No |
Answer / sadhasivaraj
defining a structure includes lots of memory space bcoz
scructure consumes lots of memory space by allocatin a
desired space during initialization
ie bcoz struct can handle different data types
Is This Answer Correct ? | 4 Yes | 1 No |
How do you construct an increment statement or decrement statement in C?
Write a pro-gramme to determine whether the number is even or odd?
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same
. Write a program to get a string and to convert the 1st letter of it to uppercase
WHAT IS HEADER?
what is a c-language.what is do.
Go through this linked list concept.While traversing through the singly linked list sometimes the following code snippet "while(head != NULL)" is used and other times "while(head->link != NULL)"is used(Here head is the pointer pointing to the first node,node has two parts data part and link part).What is the difference between head != NULL and Head->link != NULL and in which situation are they used?
explain about storage of union elements.
how many errors in c explain deply
What are preprocessor directives?
What are the uses of a pointer?
do ne body have any idea about the salary for the we r going to have interview. yup .. u got it right ..i m talking abt NIC.