Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ memory leak

The embodiment of hell
Comment

memory leak in cpp

// Program with memory leak
#include <bits/stdc++.h>
using namespace std;
 
// function with memory leak
void func_to_show_mem_leak()
{
    int* ptr = new int(5);
 
    // body
 
    // return without deallocating ptr
    return;
}
 
// driver code
int main()
{
 
    // Call the function
    // to get the memory leak
    func_to_show_mem_leak();
 
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: getline(cin string) not working 
Cpp :: c++ vector of class objects 
Cpp :: Bresenham line drawing opengl cpp 
Cpp :: Program To Calculate Number Power Using Recursion In C++. The power number should always be positive integer. 
Cpp :: how to play sounds in c++ 
Cpp :: integer range in c++ 
Cpp :: reverse sort a vector 
Cpp :: insert image using set atribute 
Cpp :: c preprocessor operations 
Cpp :: power of a number 
Cpp :: Converting to string c++ 
Cpp :: c++ operator overloading 
Cpp :: position of max element in vector c++ 
Cpp :: how to download c++ portable compiler 
Cpp :: c++ lettura file 
Cpp :: how to remove first element from vector c++ 
Cpp :: cpp map insert 
Cpp :: char to string c++ 
Cpp :: c++ average vector 
Cpp :: c++ inheritance 
Cpp :: kmp algorithm c++ 
Cpp :: take a function argument 
Cpp :: print hola mundo 
Cpp :: c++ program to print odd numbers using loop 
Cpp :: program to swap max and min in matrix 
Cpp :: c++ json parser euc-kr 
Cpp :: c++ pass ofstream as argument 
Cpp :: log base e synthax c++ 
Cpp :: shortest path in unweighted graph bfs 
Cpp :: or in c++ 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =