[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 2

newterm Subroutine


Initializes curses and its data structures for a specified terminal.


Curses Library (libcurses.a)


#include <curses.h>
SCREEN *newterm(
OutFile, InFile)
char *Type;
FILE *OutFile, *InFile;


The newterm subroutine initializes curses and its data structures for a specified terminal. Use this subroutine instead of the initscr subroutine if you are writing a program that sends output to more than one terminal. You should also use this subroutine if your program requires indication of error conditions so that it can run in a line-oriented mode on terminals that do not support a screen-oriented program.

If you are directing your program's output to more than one terminal, you must call the newterm subroutine once for each terminal. You must also call the endwin subroutine for each terminal to stop curses and restore the terminal to its previous state.


InFile Identifies the input device file.
OutFile Identifies the output device file.
Type Specifies the type of output terminal. This parameter is the same as the $TERM environment variable for that terminal.

Return Values

The newterm subroutine returns a variable of type SCREEN *. You should save this reference to the terminal within your program.


  1. To initialize curses on a terminal represented by the lft device file as both the input and output terminal, open the device file with the following:
    fdfile = fopen("/dev/lft0", "r+");

    Then, use the newterm subroutine to initialize curses on the terminal and save the new terminal in the my_terminal variable as follows:

    char termname [] = "terminaltype";
    SCREEN *my_terminal;
    my_terminal = newterm(termname,fdfile, fdfile);
  2. To open the device file /dev/lft0 as the input terminal and the /dev/tty0 (an ibm3151) as the output terminal, do the following:
    fdifile = fopen("/dev/lft0", "r");
    fdofile = fopen("/dev/tty0", "w");
    SCREEN *my_terminal2;
    my_terminal2 = newterm("ibm3151",fdofile, fdifile);
  3. To use stdin for input and stdout for output, do the following:
    char termname [] = "terminaltype";
    SCREEN *my_terminal;
    my_terminal = newterm(termname,stdout,stdin);

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

The endwin subroutine, initscr subroutine.

Curses Overview for Programming, List of Curses Subroutines, Initializing Curses in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.

[ Previous | Next | Contents | Glossary | Home | Search ]