authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-10-01 12:40:30-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-10-01 12:40:30-04:00
log4bf149795acea088b349be89cb7992a6d413ad9f
tree00d02e37ccf13cf54d291b8e0d9be99e28379d94
parenta2e6ada1c681123c8674f61b91862b5377f1dda1

update hello world examples

edge cases matter See #510

2 files changed, 10 insertions(+), 3 deletions(-)

example/hello_world/hello.zig+1-1
......@@ -1,5 +1,5 @@
11const io = @import("std").io;
22
33pub fn main() -> %void {
4 %%io.stdout.printf("Hello, world!\n");
4 %return io.stdout.printf("Hello, world!\n");
55}
example/hello_world/hello_libc.zig+9-2
......@@ -1,6 +1,13 @@
1const c = @cImport(@cInclude("stdio.h"));
1const c = @cImport({
2 @cInclude("stdio.h");
3 @cInclude("string.h");
4});
5
6const msg = c"Hello, world!\n";
27
38export fn main(argc: c_int, argv: &&u8) -> c_int {
4 _ = c.printf(c"Hello, world!\n");
9 if (c.printf(msg) != c_int(c.strlen(msg)))
10 return -1;
11
512 return 0;
613}