Search code examples
operating-systemcurses

Using curses library to create GUI for different operating systems


It would appear that the curses library is specific to the operating system. Given this, I would like to know:

  1. Can the curses library be used in a non-standard operating system (as in not Windows, Linux, Mac OS, so on...)?; and,
  2. If the curses library is not limited to those operating systems, would I have to write my own implementation of the functions described in the library or could I simply call the functions in a similar fashion as in:

    #include <stdio.h>
    ...
    printf("%s", "something");
    

Solution

  • For your first question, you can use curses in any Unix-like operating system, that includes Linux and MacOSX. Both of them provides curses. For the other operating system, you can check PDCurses. That said, you can make your code portable. However, I would not consider it for iOS, Android, etc (although still possible to do it).

    For your second question, once you use curses you have to stick with that. You can not use the standard I/O. Curses provides its own directives to print out. Instead of printf, you would use printw. Check the "Hello world" example from the curses tutorial to get an idea.