From the course: Exploring C Libraries

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Controlling the text screen

Controlling the text screen - C Tutorial

From the course: Exploring C Libraries

Start my 1-month free trial

Controlling the text screen

- [Instructor] The first thrill of controlling the terminal screen is being able to set the cursor to any valid location. And to do so, you must first obtain the width and height of the screen. In ncurses, the default output window is called the standard screen, which has the same size as the terminal window. And in this exercise file, the size is obtained by the getmaxyx function at line 10, then output at line 11. Now be aware that the variables height and width are not pointers in this function. I've already compiled and built the program so we'll run. See what the screen size is for this terminal window. And it's reporting 22 rows by 89 columns, which looks about right. Now this terminal window is a bit smaller, so you would expect a different result. I will run the same program, and ncurses reports 15 rows by 57 columns. When you know the screen's size, you can safely relocate the cursor to any position on…

Contents