From 51c1ff9df891e2f2bbdaba9627fe0611165347cf Mon Sep 17 00:00:00 2001 From: Jet Hughes Date: Thu, 11 Aug 2022 11:09:21 +1200 Subject: [PATCH] vault backup: 2022-08-11 11:09:21 --- .../notes/10-intro-to-c-arrays-malloc-free.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 content/notes/10-intro-to-c-arrays-malloc-free.md diff --git a/content/notes/10-intro-to-c-arrays-malloc-free.md b/content/notes/10-intro-to-c-arrays-malloc-free.md new file mode 100644 index 000000000..90f453a16 --- /dev/null +++ b/content/notes/10-intro-to-c-arrays-malloc-free.md @@ -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 +``` \ No newline at end of file