This way we can turn it on or off so we don't waste power.
Hope I helped! Just tell me if i'm wrong!
Answer:
// function with memory leak
void func_to_show_mem_leak() {
int *pointer;
pointer = malloc(10 * sizeof(int));
*(pointer+3) = 99;}
// driver code
int main()
{
// Call the function
// to get the memory leak
func_to_show_mem_leak();
return 0; }
Explanation:
Memory leakage occurs when programmers allocates memory by using new keyword and forgets to deallocate the memory by using delete() function or delete[] operator. One of the most memory leakage occurs by using wrong delete operator.
The delete operator should be used to free a single allocated memory space, whereas the delete [] operator should be used to free an array of data values.