Tagstack

Local, Global and Static Variables in C

L

A variable is a name we give to a memory storage area that our program can then manipulate. We can specify its size and its type depending on the values it will contain (char, int, long). But we can also control its lifespan and its scope when we declare it. This is why we need to be able to distinguish between local, global and static variables when we program in C. Local Variables Local...

Malloc: Allocating Memory in C

M

In compiled programming languages ​​like C, it is often useful, or even necessary, to allocate memory dynamically on the heap, in order to accommodate variables of larger or uncertain size. The malloc function allows us to ask the operating system to allocate an area of ​​memory to be used in our program. In order to use malloc effectively, we must understand how two different parts of memory...