取得终端长、宽

#include <stdio.h>
#include <term.h>

int main() {
        int nrows, ncolumns;
        setupterm(NULL, fileno(stdout), (int *)0);
        nrows = tigetnum("lines");
        ncolumns = tigetnum("cols");
        printf("This terminal has %d columns and %d rows\n", ncolumns, nrows);
        return 0;

posted on 2012-08-07 13:43  山本二十八  阅读(128)  评论(0编辑  收藏  举报

导航