mirror of
https://github.com/ziglang/zig.git
synced 2026-02-19 07:48:31 +00:00
fix examples
This commit is contained in:
parent
c36b0fec8e
commit
0ac1934ad6
@ -1,12 +1,12 @@
|
||||
const std = @import("std");
|
||||
const io = std.io;
|
||||
const str = std.str;
|
||||
const mem = std.mem;
|
||||
|
||||
pub fn main(args: [][]u8) -> %void {
|
||||
const exe = args[0];
|
||||
var catted_anything = false;
|
||||
for (args[1...]) |arg| {
|
||||
if (str.eql(arg, "-")) {
|
||||
if (mem.eql(u8, arg, "-")) {
|
||||
catted_anything = true;
|
||||
%return cat_stream(&io.stdin);
|
||||
} else if (arg[0] == '-') {
|
||||
@ -38,7 +38,7 @@ fn cat_stream(is: &io.InStream) -> %void {
|
||||
var buf: [1024 * 4]u8 = undefined;
|
||||
|
||||
while (true) {
|
||||
const bytes_read = is.read(buf) %% |err| {
|
||||
const bytes_read = is.read(buf[0...]) %% |err| {
|
||||
%%io.stderr.printf("Unable to read from stream: {}\n", @errorName(err));
|
||||
return err;
|
||||
};
|
||||
|
||||
@ -18,7 +18,7 @@ pub fn main(args: [][]u8) -> %void {
|
||||
%%io.stdout.printf("\nGuess a number between 1 and 100: ");
|
||||
var line_buf : [20]u8 = undefined;
|
||||
|
||||
const line_len = io.stdin.read(line_buf) %% |err| {
|
||||
const line_len = io.stdin.read(line_buf[0...]) %% |err| {
|
||||
%%io.stdout.printf("Unable to read from stdin: {}\n", @errorName(err));
|
||||
return err;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user