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 |
Explain what is meant by high-order and low-order bytes?
How to set file pointer to beginning c?
Eight queens puzzle
What is null pointer in c?
#define MAX 3 main() { printf("MAX = %d ",MAX ); #undef MAX #ifdef MAX printf("Vector Institute”); #endif }
program for following output using for loop? 1 2 3 4 5 2 3 4 5 3 4 5 4 5 5
What are void pointers in c?
while initialization of array why we use a[][2] why not a[2][]...?
write a function that accepts an array A with n elements and array B with n-1 elements. Find the missing one in array B,with an optimized manner?
Write a c program using for loop to print typical pattern if number of rows is entered by keyboard. ABCBA AB BA A A
What are the types of type qualifiers in c?
Explain about the functions strcat() and strcmp()?