讀寫檔案#
zig 版本 0.11.0-dev.2837+b55b8e774
const std = @import("std");
pub fn main() !void {
const value = "你好";
var my_file = try std.fs.cwd().createFile("file.txt", .{ .read = true });
defer my_file.close();
_ = try my_file.write(value);
var buf: [value.len]u8 = undefined;
try my_file.seekTo(0);
const read = try my_file.read(&buf);
std.debug.print("{s}", .{buf[0..read]});
}