Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/File-input-output/Zig/file-input-output.zig
Normal file
16
Task/File-input-output/Zig/file-input-output.zig
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
var in = try std.fs.cwd().openFile("input.txt", .{});
|
||||
defer in.close();
|
||||
var out = try std.fs.cwd().openFile("output.txt", .{ .mode = .write_only });
|
||||
defer out.close();
|
||||
var file_reader = in.reader();
|
||||
var file_writer = out.writer();
|
||||
var buf: [100]u8 = undefined;
|
||||
var read: usize = 1;
|
||||
while (read > 0) {
|
||||
read = try file_reader.readAll(&buf);
|
||||
try file_writer.writeAll(buf[0..read]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue