From b9b2ccd5155f8ce14cc9b4b04fffe56b988a3bdd Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Wed, 1 Feb 2017 23:12:40 +0100 Subject: Pointer arithmetic! --- nl/string_index.nl | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 nl/string_index.nl (limited to 'nl') diff --git a/nl/string_index.nl b/nl/string_index.nl new file mode 100644 index 0000000..27df14b --- /dev/null +++ b/nl/string_index.nl @@ -0,0 +1,12 @@ +extern func void(i32) putchar; + +i32 main() { + ptr(i8) s = "kaas"; + i32 i = 0; + while (*(s+i) != '\x00') { + putchar(*(s + i)); + i = i + 1; + } + putchar('\n'); + return 0; +} -- cgit v1.2.3-70-g09d2