ncurses
Ncurses is a simple graphics library that can be used to create basic graphical user interfaces (GUI) for games and other things. Although no longer as popular as it once was, we still use it since the CS50 IDE is not a full operating system and thus is not capable of rendering the graphics of richer libraries like SPL.
To start off, let’s write a hello world program. Furthermore, when learning a new programming language, or, as in this case, when becoming familiar with a new library, it’s always a good idea to begin with a very straightforward program. This way, we’ll get some important practice with the basic setup we need to use ncurses.
First, take a look at the video below, demonstrating how to write “Hello world” using ncurses. Next, continue along to the second video. Watch it first to get a sense of what types of games we can create with ncurses. Then, check out the program’s code and other documentation, available on GitHub and linked under the video. Good luck!
-
Videos (Part 0)
- Giga Raptor on Hello World with ncurses
- For documentation on writing hello world using ncurses, click here.
-
Videos (Part 1)
- _Eetu on Snake Game with ncurses
- Code for the above program can be found here on GitHub.
-
Slides
-
Notes
-
Supplementary Resources
- Thomas E. Dickey on Ncurses - Frequently Asked Questions
- Pradeep Padala on Ncurses Programming, How To
- Ben Moore on Learn to Use Ncurses By Building Snake
- Yu-Jie Lin on Grand digital clock
- Code for the above program can be found here on GitHub.
-
Thought Questions
- Why do we use libraries in programming? Why is documentation for these important?
- If you had to write a library that abstracted away from your daily routines, what would be some of its functions?
- Ncurses is “free software.” What do we mean by this? And what is the difference between “free software” and “open source”? (Hint: Check out Scott K. Peterson’s article on this difference here.)