printw, wprintw, mvprintw, or mvwprintw Subroutine

Purpose

Performs a printf command on a window using the specified format control string.

Library

Curses Library (libcurses.a)

Syntax

#include <curses.h>

printw( Format, [ Argument ...])
char *Format, *Argument;

wprintw( Window, Format, [Argument ...])
WINDOW *Window;
char *Format, *Argument;

mvprintw( Line,  Column, Format, [Argument ...])
int Line, Column;
char *Format, *Argument;

mvwprintw(Window, Line, Column, Format, [Argument ...])

WINDOW *Window;
int Line, Column;
char *Format, *Argument; 

Description

The printw, wprintw, mvprintw, and mvwprintw subroutines perform output on a window by using the specified format control string. However, the waddch (addch, mvaddch, mvwaddch, or waddch Subroutine) subroutine is used to output characters in a given window instead of invoking the printf subroutine. The mvprintw and mvwprintw subroutines move the logical cursor before performing the output.

Use the printw and mvprintw subroutines on the stdscr and the wprintw and mvwprintw subroutines on user-defined windows.

Note: The maximum length of the format control string after expansion is 512 bytes.

Parameters

Item Description
Argument Specifies the item to print. See the printf subroutine for more details.
Column Specifies the horizontal position to move the cursor to before printing.
Format Specifies the format for printing the Argument parameter. See the printf subroutine.
Line Specifies the vertical position to move the cursor to before printing.
Window Specifies the window to print into.

Examples

  1. To print the user-defined integer variables x and y as decimal integers in the stdscr, enter:
    int x, y;
    printw("%d%d", x, y);
  2. To print the user-defined integer variables x and y as decimal integers in the user-defined window my_window, enter:
    int x, y;
    WINDOW *my_window;
    wprintw(my_window, "%d%d", x, y);
  3. To move the logical cursor to the coordinates y = 5, x = 10 before printing the user-defined integer variables x and y as decimal integers in the stdscr, enter:
    int x, y;
    mvprintw(5, 10, "%d%d", x, y);
  4. To move the logical cursor to the coordinates y = 5, x = 10 before printing the user-defined integer variables x and y as decimal integers in the user-defined window my_window, enter:
    int x, y;
    WINDOW *my_window;
    mvwprintw(my_window, 5, 10, "%d%d", x, y);