aboutsummaryrefslogtreecommitdiff
path: root/examples/cli.zc
blob: 113a0da220cbd15a6ddf9247e45d6028717b4f03 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
// print the length and first character of the file named by ZC_FILE
include "src/lib/std.zc";
fn main() {
	let name[80], s, n;
	n = Host.env("ZC_FILE", name, 80);
	if (n < 0) { put_s("no file\n"); return 1; }
	s = readfile(name);
	if (!s) { put_s("can't read\n"); return 1; }
	put_n(len_w(s)); put_c(' '); put_c(s[0]); put_c(10);
	free(d*s);
	return 0;
}