![]() |
![]() |
![]() |
C++ Reference: free()
free()
Declaration
void free(void* vpMemory);
Description
Deallocates a block of dynamically allocated memory that was previously allocated by calloc, malloc, or realloc.
Example
#include <iostream>
#include <cstdlib>
int main() {
using namespace std;
int* ipArray = (int*)calloc(7, sizeof(int));
// Output the elements to verift that they have been set to zero.
for (int iIndex = 0; iIndex < 7; ++iIndex) {
cout << " " << ipArray[iIndex];
}
cout << endl;
// Deallocate the memory
free(ipArray);
return 0;
}
Output:
![]() |
![]() |
![]() |
| Home | | | Reference | | | Play Games! | | | Blog | | | Forum | | | Site Map | | | Contact Us |





