How to get console width without using ncurses?

120 views Asked by At

What I need is only the console width, so it is better to not depend on another library that provides many other functions. In addition, the user of my library probably don't have ncurses dev headers installed; so if I remove the dependency on ncurses, there will be less claims from my user.

I have downloaded ncurses source code and had a brief look at it, but failed to grasp the key code for collecting the console width. I know fcntl() can do it, but Windows probably don't have it. Could anybody tell me how to get the width in a cross-platform way?

1

There are 1 answers

0
Fabel On

You find it in the COLUMNS environment variable.