mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-25 05:44:06 -06:00
vault backup: 2022-08-11 11:09:21
This commit is contained in:
parent
92c48e7b33
commit
51c1ff9df8
30
content/notes/10-intro-to-c-arrays-malloc-free.md
Normal file
30
content/notes/10-intro-to-c-arrays-malloc-free.md
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
title: "10-intro-to-c-arrays-malloc-free"
|
||||
aliases:
|
||||
tags:
|
||||
- cosc204
|
||||
---
|
||||
|
||||
# Arrays
|
||||
- must declare with size
|
||||
|
||||
``` c
|
||||
uint32_t array[10];
|
||||
float matrix[5][6];
|
||||
```
|
||||
|
||||
- do not have methods
|
||||
- array.size etc
|
||||
- not bounds checked
|
||||
- can write past the end
|
||||
- to know must keep trach yourself or use sentinel value
|
||||
- 'H' 'e' 'l' 'l' 'o' '\0' <- sentinel value
|
||||
|
||||
``` c
|
||||
char *check = thing;
|
||||
|
||||
while(*check != '\0')
|
||||
check++
|
||||
|
||||
length = check - thing
|
||||
```
|
||||
Loading…
Reference in New Issue
Block a user