Simple lib that mimic linux wc but written in Zig by Diego Pacheco
100% working with Zig 0.11.
zig build
zig test wc.zig
All 2 tests passed.
zig build -Doptimize=ReleaseFast
cat example/file.txt | zig-out/bin/wc
5
const std = @import("std");
const wc = @import("wc");
pub fn main() !void {
var file = try std.fs.cwd().openFile("file.txt", .{});
defer file.close();
var reader = file.reader();
const counter = wc.WordCounter{};
const result: i64 = try counter.count(reader);
std.debug.print("file.txt count = {d}", .{result});
}
cd example/
zig build run
file.txt count = 5%