summaryrefslogtreecommitdiff
path: root/nl
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-02-01 23:12:40 +0100
committertomsmeding <tom.smeding@gmail.com>2017-02-01 23:12:40 +0100
commitb9b2ccd5155f8ce14cc9b4b04fffe56b988a3bdd (patch)
treee319d2162552222a0aebcd1f10007670b33e40cb /nl
parent44ccdb3c72fad6daf995c0354e3ab75a3260ca9c (diff)
Pointer arithmetic!
Diffstat (limited to 'nl')
-rw-r--r--nl/string_index.nl12
1 files changed, 12 insertions, 0 deletions
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;
+}