summaryrefslogtreecommitdiff
path: root/nl
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-02-02 09:41:01 +0100
committertomsmeding <tom.smeding@gmail.com>2017-02-02 09:41:01 +0100
commit9e67d68574bf4b78451469d5e149cfd95b0ec9f6 (patch)
tree5a3a8d6f33297a6ade37b58cc79d6df499de8b8d /nl
parent6416151b73b28db208c02b133b058e51b28ff2c8 (diff)
Pointer arithmetic now also for Minus
string_index.nl now doesn't compile anymore because I need to implement casts from i32 to u64
Diffstat (limited to 'nl')
-rw-r--r--nl/string_index.nl7
1 files changed, 5 insertions, 2 deletions
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');