blob: 41f77394d68bd5c983119667c3b63b2616fa9251 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
const std = @import("std");
const Foo = extern struct {
x: u8,
y: u8,
z: u8,
};
pub fn main() !void {
const f = std.fs.cwd().createFile("moose", .{ .truncate = true }) catch unreachable;
// Write raw byte slice.
try f.writeAll(&[_]u8{ 1, 2, 3, 4 });
// Write raw byte slice (ascii chars).
try f.writeAll("abcd");
// Format printing.
const w = f.writer();
try w.print("{}-{}", .{ 8, 9 });
// Write struct to file.
try w.writeStruct(Foo{ .x = 0xaa, .y = 0xbb, .z = 0xcc });
}
|