summaryrefslogtreecommitdiff
path: root/nl/string_index.nl
blob: 55bbc0883618d7ed8ff0dd0b91eda44db9988c99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
extern func void(i32) putchar;
extern func u64(ptr(i8)) strlen;
extern func ptr(i8)(u64) malloc;

void printnum(i32 n) {
	if (n < 0) {
		putchar('-');
		n = -n;
	}
	if (n == 0) {
		putchar('0');
		return;
	}
	while (n > 0) {
		putchar('0' + n % 10);
		n = n / 10;
	}
}

i32 main() {
	ptr(i8) s = "kaas";
	i32 i = 0;
	while (i < cast(i32)(strlen(s))) {
		putchar(s[i]);
		i = i + 1;
	}
	putchar('\n');

	/*ptr(i32) arr = cast(ptr(i32))(malloc(4U*16U));
	arr[0] = 1;
	arr[1] = 1;
	i32 i = 2;
	while (i < 16) {
		arr[i] = arr[i-2] + arr[i-1];
		i = i + 1;
	}
	i = 0;
	while (i < 16) {
		printnum(arr[i]);
		putchar(' ');
	}
	putchar('\n');*/
	return 0;
}