#Get amount of rows and columns in console.
1 messages · Page 1 of 1 (latest)
I guess whatever the equivalent
#include <sys/ioctl.h>
#include <stdio.h>
#include <unistd.h>
int main (int argc, char **argv)
{
struct winsize w;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
printf ("lines %d\n", w.ws_row);
printf ("columns %d\n", w.ws_col);
return 0; // make sure your main returns int
}
of this
const std = @import("std");
const linux = std.os.linux;
pub fn main() void {
var w: linux.winsize = undefined;
_ = linux.ioctl(linux.STDOUT_FILENO, linux.T.IOCGWINSZ, @intFromPtr(&w));
std.debug.print(
\\lines {d}
\\columns {d}
\\
, .{ w.ws_row, w.ws_col });
}
oh, i see