How can I find the width of a command line window from a GNU C++-program ?
I'll use this information to display a progress bar when copying files, so I need to know the width to be able to display the progress bar correctly.
it@61@sec
29
Junior Poster in Training
Recommended Answers
Jump to PostTo expand on what Duoas mentioned about
TIOCGWINSZ
, here is an example:#include <stdio.h> #include <unistd.h> #include <ioctl.h> #include <termios.h> int main () { struct winsize ws; ioctl (STDOUT_FILENO, TIOCGWINSZ, &ws); printf ("Window width: %zd\n", ws.ws_col); return 0; }
All 4 Replies
rubberman
1,355
Nearly a Posting Virtuoso
Featured Poster
Duoas
1,025
Postaholic
Featured Poster
L7Sqr
227
Practically a Master Poster
L7Sqr
227
Practically a Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.