1

i tried to use LINES = atoi(getenv("LINES")) in windows (visual studio 2012), but it doesn't work.
Someone told me that I have to add export LINES to .bashrc or .profile.
Will that solve my problem?

If it does, how to add export LINES to .bashrc or .profile?

Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
user3084686
  • 75
  • 1
  • 6
  • 1
    Please see the example posted in an earlier stack overflow post. [Getting Terminal Size in C for Windows][1] [1]: http://stackoverflow.com/questions/6812224/getting-terminal-size-in-c-for-windows – Chadrick Dec 10 '13 at 02:59

3 Answers3

2

You almost certainly want GetConsoleScreenBufferInfo to retrieve the screen buffer info (and GetStdHandle to get the console handle).

Eric Brown
  • 13,774
  • 7
  • 30
  • 71
1

There's neither .bashrc nor .bash_profile on Windows. In order to get the current console window size, use the GetConsoleScreenBufferInfo API. Look it up. Since the window is resizable, you might want to watch that size. Use ReadConsoleInput or PeekConsoleInput to check for window resizing.

Why are you trying to get the console window dimensions, and why won't you write a proper GUI application instead?

Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
0

If you are working in Visual Studio, and you just set the LINES variable, you need to first restart the IDE after setting the environment variable. Otherwise, getenv() will not return it in the processes spawned by the IDE.

the swine
  • 10,713
  • 7
  • 58
  • 100