diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-02-02 09:41:01 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-02-02 09:41:01 +0100 |
commit | 9e67d68574bf4b78451469d5e149cfd95b0ec9f6 (patch) | |
tree | 5a3a8d6f33297a6ade37b58cc79d6df499de8b8d /nl | |
parent | 6416151b73b28db208c02b133b058e51b28ff2c8 (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.nl | 7 |
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'); |