printw3
Write formatted output to a curses window
Part of curs_printw(3).
Usage
#include <curses.h>
int printw(const char *fmt, ...); int wprintw(WINDOW *win, const char *fmt, ...); int mvprintw(int y, int x, const char *fmt, ...); int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...);
int vw_printw(WINDOW *win, const char *fmt, va_list varglist);
/* obsolete */ int vwprintw(WINDOW *win, const char *fmt, va_list varglist);
Overview
printw, wprintw, mvprintw, and mvwprintw are analogous to printf(3). In effect, the string that would be output by printf(3) is instead output as though waddstr(3X) were used with win (or stdscr) as its first argument.
vwprintw and vw_printw are analogous to vprintf(3), and perform a wprintw using a variable argument list. The third argument is a va_list, a pointer to a list of arguments, as defined in stdarg.h.
Return value
These functions return ERR upon failure and OK upon success.
In ncurses, failure occurs if the library cannot allocate enough memory for the buffer into which the output is formatted, or if the window pointer win is null.
Functions prefixed with “mv” first perform cursor movement and fail if the position (y, x) is outside the window boundaries.
Notes
No wide character counterpart functions are defined by the “wide” ncurses configuration nor by any standard. To format and write a wide-character string to a curses window, consider using swprintf(3) and waddwstr(3X) or similar.
Portability
X/Open Curses Issue 4 describes these functions. It specifies no error conditions for them.
ncurses defines vw_printw and vwprintw identically to support legacy applications. However, the latter is obsolete.
- •
-
X/Open Curses Issue 4 Version 2 (1996), marked vwprintw as requiring varargs.h and “TO BE WITHDRAWN”, and specified vw_printw using the stdarg.h interface.
- •
-
X/Open Curses Issue 5, Draft 2 (December 2007) marked vwprintw (along with vwscanw and the termcap interface) as withdrawn. After incorporating review comments, this became X/Open Curses Issue 7 (2009).
- •
-
ncurses provides vwprintw, but marks it as deprecated.
Releases
83 releases since FreeBSD 2.2.2-RELEASE; the text changed 13 times.