I'm learning Zig, coming from C# and TypeScript, but still have dusty C knowledge from the old days.
To get started, I want to write a small program that changes a few characters in a text file. This is read in line by line, each line being read into the same 1024 character buffer. For conversion I use a second buffer, in which the text line is copied character by character, changing some characters.
I have written the following function for this:
fn convLine(in_line: []const u8, out_line: []u8) !void { for (in_line, 0..) |_, i| { out_line[i] = switch (in_line[i]) { ',' => ';', '.' => ',', else => in_line[i], }; } //outline.len = in_line.len; // doesnt work }
The problem is that out_line.len is always the buffer size. Is the 0 termination byte not copied? Do I think too C-ish?