authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-02-26 14:35:30-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-02-26 14:35:30-05:00
log0ac1934ad64716adeb98620003a0b905fb5cfda6
treeadd32da862061aa05531dfe84cab939371d2d055
parentc36b0fec8e9b71aaa54c3966be5db0e0d7895463

fix examples


2 files changed, 4 insertions(+), 4 deletions(-)

example/cat/main.zig+3-3
...@@ -1,12 +1,12 @@...@@ -1,12 +1,12 @@
1const std = @import("std");1const std = @import("std");
2const io = std.io;2const io = std.io;
3const str = std.str;3const mem = std.mem;
44
5pub fn main(args: [][]u8) -> %void {5pub fn main(args: [][]u8) -> %void {
6 const exe = args[0];6 const exe = args[0];
7 var catted_anything = false;7 var catted_anything = false;
8 for (args[1...]) |arg| {8 for (args[1...]) |arg| {
9 if (str.eql(arg, "-")) {9 if (mem.eql(u8, arg, "-")) {
10 catted_anything = true;10 catted_anything = true;
11 %return cat_stream(&io.stdin);11 %return cat_stream(&io.stdin);
12 } else if (arg[0] == '-') {12 } else if (arg[0] == '-') {
...@@ -38,7 +38,7 @@ fn cat_stream(is: &io.InStream) -> %void {...@@ -38,7 +38,7 @@ fn cat_stream(is: &io.InStream) -> %void {
38 var buf: [1024 * 4]u8 = undefined;38 var buf: [1024 * 4]u8 = undefined;
3939
40 while (true) {40 while (true) {
41 const bytes_read = is.read(buf) %% |err| {41 const bytes_read = is.read(buf[0...]) %% |err| {
42 %%io.stderr.printf("Unable to read from stream: {}\n", @errorName(err));42 %%io.stderr.printf("Unable to read from stream: {}\n", @errorName(err));
43 return err;43 return err;
44 };44 };
example/guess_number/main.zig+1-1
...@@ -18,7 +18,7 @@ pub fn main(args: [][]u8) -> %void {...@@ -18,7 +18,7 @@ pub fn main(args: [][]u8) -> %void {
18 %%io.stdout.printf("\nGuess a number between 1 and 100: ");18 %%io.stdout.printf("\nGuess a number between 1 and 100: ");
19 var line_buf : [20]u8 = undefined;19 var line_buf : [20]u8 = undefined;
2020
21 const line_len = io.stdin.read(line_buf) %% |err| {21 const line_len = io.stdin.read(line_buf[0...]) %% |err| {
22 %%io.stdout.printf("Unable to read from stdin: {}\n", @errorName(err));22 %%io.stdout.printf("Unable to read from stdin: {}\n", @errorName(err));
23 return err;23 return err;
24 };24 };