I was recently trying to get the size of the terminal in which this program is run.
The problem is that the script + program solution is not handy and it does not support user input or terminal size change.
How can I do that in the C++ code (without messing with the scripts)?
My code:
Bash file (file to be run instead of the C++ program):
cols=`tput cols`
lines=`tput lines`
input="${cols}\n${lines}"
echo -ne "${input}" | [C++ program]
C++ file (the actual program):
#include <iostream>
int main() {
unsigned lines;
unsigned cols;
cin >> cols;
cin >> lines;
// some code here
}