Zeke Xiao

Zeke Xiao

github

Zig 代碼片段

讀寫檔案#

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]});
}
載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。