COMP1850 Lecture 5.1 C Arrays and Dynamic Memory Allocation

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/21

flashcard set

Earn XP

Description and Tags

Flashcards covering arrays, memory allocation, and strings in C.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

22 Terms

1
New cards

Array

Collection of a primitive data type in C.

2
New cards

Statically typed arrays

Arrays where the array can only store one type of data.

3
New cards

Stack Memory

Memory reserved for static program data, managed by the compiler, and a last-in-first-out (LIFO) data structure.

4
New cards

Heap Memory

Memory available for dynamic program data, accessed through pointers, and a flexible unordered address space.

5
New cards

For loops

Operating on arrays requires us to iterate through the data structure

6
New cards

Zero

Arrays and other variables are not automatically initialised to _ in C.

7
New cards

Inline

C allows definition and initialisation of arrays _, similarly to primitive data types.

8
New cards

Matrix

A 2-dimensional array.

9
New cards

Right-most

For high-performance applications it is important to access arrays such that the _ index varies fastest.

10
New cards

String

An array of char type with an additional null character ('\0') that signifies the end of the string.

11
New cards

The C library that defines common string handling operations.

12
New cards

Static arrays

Arrays allocated at compile-time using stack memory.

13
New cards

Variable-length arrays (VLAs)

A C99+ language feature using stack memory, not resizeable once allocated.

14
New cards

Dynamic arrays

Original language feature using heap memory.

15
New cards

Pointer

A data type that can store a memory address.

16
New cards

malloc

C standard library utility functions: Allocate an item of given type.

17
New cards

calloc

C standard library utility functions: Allocate an array of a given type.

18
New cards

free

C standard library utility functions: Release allocated memory.

19
New cards

sizeof()

A portable way of calculating the correct amount of memory, which uses the locally defined amounts for that machine.

20
New cards

realloc()

The standard library utility for resizing allocated memory.

21
New cards

Garbage collection

The concept where many languages allocate and deallocate (free) dynamic memory silently.

22
New cards

Array-pointer duality

The properties where arrays and pointers are closely linked in C.