C ++ console screen size

So, I study some things in college in C ++, and the teacher and I discussed how to actually center the text on the output screen. Therefore, my suggestion was to use setw, but get the length of the line and sizethe console screen, make the algorithm and BAM we have a really centered text. He says that the screen size 80, but the screen can be resized, which does not work, no matter what, if the result is centered, the user starts to resize. The only small question I have is how to get the actual screen size of the console?

#include <iostream>
#include <string>
using namespace std;

const int SCR_SIZE = 80;//some way of telling size

int main(){
   string randomText = "Hello User!";
   cout << setw( ( (80 / 2) + (randomText.length() / 2 ) ) ) 
        << randomText 
        << endl;

   return 0;
}

I searched a bit and found this bit

 #include <cstdlib>

 system("MODE CON COLS=25 LINES=22");

, , , - , ? , 100% , ++.

+4
2

#include <windows.h> GetConsoleScreenBufferInfo. , Windows , GetStdHandle.

, Windows ( , Linux, Mac OS, * BSD ..)

+4

, , , , cmd. , , , , . , Windows Windows?

0

All Articles