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

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

/*

Expected stdout:

hello world!

Expected return: 0

*/