C (programming language): Difference between revisions

From David's Wiki
No edit summary
Tag: Reverted
No edit summary
Tag: Manual revert
 
Line 1: Line 1:
C is a low-level programming language primarilly used for kernel and embedded development.<br>
C is a low-level programming language primarilly used for kernel and embedded development.
These days, we mostly are concerned with C only when dealing with interop across programming languages.


==Usage==
==Usage==

Latest revision as of 19:29, 8 January 2024

C is a low-level programming language primarilly used for kernel and embedded development.

Usage

Memory Allocation

#include <stdlib.h>
There are 2 primary ways to allocate memory in C:

  • malloc(bytes) Allocated memory is uninitialized.
  • calloc(number, bytes) Allocated memory is initialized to 0. Allocates (number * bytes) bytes of memory.

Memory allocated by malloc and calloc are on the heap and should be deallocated by free when no longer used to avoid memory leaks.

alloca