Skip to content

diegopacheco/zig-wc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zig-wc

Simple lib that mimic linux wc but written in Zig by Diego Pacheco
100% working with Zig 0.11.

Build

zig build

Tests

zig test wc.zig
All 2 tests passed.

Release

zig build -Doptimize=ReleaseFast

Running it

cat example/file.txt | zig-out/bin/wc
5

Usage as lib API

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});
}

Build and run the Example

cd example/
zig build run
file.txt count = 5%

About

Simple lib that mimic linux wc but written in Zig.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages