Lecture overview -- Keyboard shortcut: 'u'  Previous page: C Program organization -- Keyboard shortcut: 'p'  Next page: The standard library -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 1 - Page 25 : 29
Notes about C++
From C to C++
Memory Allocation

Two functions for allocation of memory from the heap

A function for deallocation of the memory

From <stdlib.h>

  • Allocation functions

    • malloc(size)

    • calloc(number_of_objects, size_of_object)

    • These functions return a null pointer in case of problems

  • Reallocation - resizing of allocated object

    • realloc(ptr, newsize)

  • Deallocation

    • free(ptr)

In C++ the new and delete functions are used instead of malloc, calloc and free

Go to exerciseDynamic allocation of persons and addresses