AI Features

Sharing Memory Between Functions and Ownership

Learn about memory ownership.

We'll cover the following...

Introduction

The ownership of local variables is clear. A function creates a local variable, uses it, and upon finishing its execution, it deallocates the local data.

We say that the function owns the variables or the memory. For example:

void func()
{
    int x = 3;
    x = x + 5;

    printf("%d\n", x):
}

The scope of the local variable x ...