From 9e67d68574bf4b78451469d5e149cfd95b0ec9f6 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Thu, 2 Feb 2017 09:41:01 +0100 Subject: Pointer arithmetic now also for Minus string_index.nl now doesn't compile anymore because I need to implement casts from i32 to u64 --- nl/string_index.nl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'nl') diff --git a/nl/string_index.nl b/nl/string_index.nl index 27df14b..deb4188 100644 --- a/nl/string_index.nl +++ b/nl/string_index.nl @@ -1,10 +1,13 @@ extern func void(i32) putchar; +extern func u64(ptr(i8)) strlen; i32 main() { ptr(i8) s = "kaas"; + ptr(i8) orig = s; + s = s + strlen(s) - 1; i32 i = 0; - while (*(s+i) != '\x00') { - putchar(*(s + i)); + while (i < strlen(orig)) { + putchar(*(s - i)); i = i + 1; } putchar('\n'); -- cgit v1.2.3-70-g09d2