about summary refs log tree commit diff
path: root/examples/19.src
blob: 5320ef818678205cb4c68397405fcc5d24865ec0 (plain) (blame)
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
extern printf = (*i64, varargs) => void;
extern malloc = (i64) => *i8;
extern free = (*i64) => void;

let main = () => i64 {
	let buf = malloc(13);
	(*(buf+0)) = 'h';
	(*(buf+1)) = 'e';
	(*(buf+2)) = 'l';
	(*(buf+3)) = 'l';
	(*(buf+4)) = 'o';
	(*(buf+5)) = ' ';
	(*(buf+6)) = 'w';
	(*(buf+7)) = 'o';
	(*(buf+8)) = 'r';
	(*(buf+9)) = 'l';
	(*(buf+10)) = 'd';
	(*(buf+11)) = '\n';
	(*(buf+12)) = '\0';
	printf("%s", buf);
	free(buf);
	return 0;
};

/*

Expected stdout:

hello world!

Expected return: 0

*/