Getting terminal width in C?

后端 未结 8 735
自闭症患者
自闭症患者 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 17:03

    Here are the function calls for the already suggested environmental variable thing:

    int lines = atoi(getenv("LINES"));
    int columns = atoi(getenv("COLUMNS"));
    

提交回复
热议问题