Getting terminal width in C?

后端 未结 8 661
自闭症患者
自闭症患者 2020-11-22 16:07

I\'ve been looking for a way to get the terminal width from within my C program. What I keep coming up with is something along the lines of:

#include 

        
8条回答
  •  感情败类
    2020-11-22 16:47

    So not suggesting an answer here, but:

    linux-pc:~/scratch$ echo $LINES

    49

    linux-pc:~/scratch$ printenv | grep LINES

    linux-pc:~/scratch$

    Ok, and I notice that if I resize the GNOME terminal, the LINES and COLUMNS variables follow that.

    Kinda seems like GNOME terminal is creating these environment variables itself?

提交回复
热议问题