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 :: Unsorted Linked list in c++ 
Cpp :: C++ Multi-line comments 
Cpp :: c++ check if string is empty 
Cpp :: g++ optimization flags 
Cpp :: malloc in c++ 
Cpp :: how to read a comma delimited file into an array c++ 
Cpp :: Appending a vector to a vector in C++ 
Cpp :: arduino buildin let 
Cpp :: c++ length of char* 
Cpp :: character array to string c++ stl 
Cpp :: c++ hours minutes seconds 
Cpp :: c++ string comparison 
Cpp :: iterating in map/unordered map c++ 
Cpp :: check if file is empty c++ 
Cpp :: prime numbers less than a given number c++ 
Cpp :: c++ char it is a number 
Cpp :: Write C++ program to sort an array in ascending order 
Cpp :: c++ function for checking if a sting is a number 
Cpp :: primes in range cpp 
Cpp :: c++ 
Cpp :: restting a queue stl 
Cpp :: c++ template function 
Cpp :: OpenGL C++ Version 
Cpp :: c++ remove text file 
Cpp :: C++ Vector Iterator Syntax 
Cpp :: Accpt array input in single line in cpp 
Cpp :: stack implementation using class in c++ 
Cpp :: sizeof’ on array function parameter ‘arr’ will return size of ‘int*’ [-Wsizeof-array-argument] 
Cpp :: panic: assignment to entry in nil map 
Cpp :: #define online judge in cpp 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =