title: c++ console screen size
body: <p>So I'm learning some stuff in College on C++, and the teacher and I got into a discussion on how to actually center text to the output screen. So my suggestion was to use <code>setw</code> but get the length of the string and the <code>size</code> of the console screen, do the algorithm and BAM we have truly centered text. He says the screen size is <code>80</code> but the screen can be resized, which doesn't work no matter what if the output is centered the the user starts resizing. Just a minor question I have, how to get the actual size of the console screen?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  const int SCR_SIZE = 80;//some way of telling size
  
  int main(){
     string randomText = "Hello User!";
     cout &lt;&lt; setw( ( (80 / 2) + (randomText.length() / 2 ) ) ) 
          &lt;&lt; randomText 
          &lt;&lt; endl;
  
     return 0;
  }
  </code></pre>
  
  <p>Searched a little and found this bit</p>
  
  <pre><code> #include &lt;cstdlib&gt;
  
   system("MODE CON COLS=25 LINES=22");
  </code></pre>
  
  <p>Would that work to set it on execution to make sure my size is what I want it to be? Just read through it so I'm not 100% positive if that in fact is a c++ library</p>