title: How can I find the number of terminal columns from a C/C++ program?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1022957/getting-terminal-width-in-c">Getting terminal width in C?</a>  </p>
  </blockquote>
  
  
  
  <p>On Linux and OS X, my shell reports $COLUMNS has the width of the terminal window -- and resizing the window will adjust this shell variable.</p>
  
  <p>But in my C/C++ program, getenv("COLUMNS") doesn't seem to find the variable.</p>
  
  <p>Anybody have an explanation?  Or an alternate suggestion for letting my C++ program figure out the width of the terminal it's running in (for some help message word wrapping)?</p>