printw(3NCURSES)
๐ printw โ write formatted output to a curses window ๐
okay bestie, so this is printw(3NCURSES), one of the library calls in the ncurses fam, and honestly? it's giving printf but make it โจwindowโจ. let's get into it.
๐ธ NAME ๐ธ
printw, wprintw, mvprintw, mvwprintw, vwprintw, vw_printw โ write formatted output to a curses window ๐ซถ
โจ SYNOPSIS โจ
#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);
heads up bestie: that last one,vwprintw, is marked/* obsolete */right there in the source. it's giving "still invited to the party but sitting at the kids' table." ๐
๐ DESCRIPTION ๐
so printw, wprintw, mvprintw, and mvwprintw are literally analogous to printf(3). like, the way that they work? the string that printf(3) would have output just gets output as though waddstr(3NCURSES) had been used instead, with win (or stdscr) as its first argument. same energy, different destination. periodt. ๐
and then vwprintw and vw_printw? they're analogous to vprintf(3), and they perform a wprintw using a variable argument list. the third argument is a va_list, which is a pointer to a list of arguments, as defined in stdarg.h. iykyk. ๐ธ
๐ฅ RETURN VALUE ๐ฅ
these functions return ERR upon failure and OK upon success. simple as that, no cap.
in ncurses, failure happens if the library cannot allocate enough memory for the buffer into which the output is formatted, or if the window pointer win is null. (null window pointer? not the vibe. ๐)
and the functions prefixed with โmvโ โ so mvprintw and mvwprintw โ first perform cursor movement, and they fail if the position (y, x) is outside the window boundaries. stay in your lane, literally. ๐
๐ง NOTES ๐ง
there are no wide character counterpart functions defined by the โwideโ ncurses configuration, and none by any standard either. so if you wanna format and write a wide-character string to a curses window, consider using swprintf(3) and waddwstr(3NCURSES) or something similar. bestie, work with what you've got. ๐
๐ PORTABILITY ๐
X/Open Curses Issue 4 describes these functions. it specifies no error conditions for them. (iconic of it, honestly.)
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
vwprintwas requiringvarargs.hand โTO BE WITHDRAWNโ, and specifiedvw_printwusing thestdarg.hinterface. - X/Open Curses Issue 5, Draft 2 (December 2007) marked
vwprintw(along withvwscanwand 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.
the drama of it all: vwprintw has been getting "TO BE WITHDRAWN" and "deprecated" notes for decades. it's the main character who refuses to leave the group chat. ๐ญ
๐ HISTORY ๐
4BSD (1980) introduced wprintw and its variants. it implemented all of them as functions, not macros โ and this initial distribution of curses actually preceded the ANSI C standard of 1989, prior to which a variadic macro facility was not widely available in the language. printw went unused in Berkeley distributions until 4.1cBSD (1983), which employed it in games. (gaming, always the early adopter. ๐ฎ)
4BSD's wprintw did not use varargs.h, which had been available since Seventh Edition Unix (1979). in 1991 โ a couple of years after SVr4 was generally available, and after the C standard was published โ other developers updated the library, using stdarg.h internally in 4.4BSD curses. even with this improvement, BSD curses did not use function prototypes (nor even declare functions) in curses.h until 1992. the glow-up took a minute, okay? ๐
4BSD documented printw and wprintw tersely as โprintf on stdscrโ and โprintf on winโ, respectively. minimalism era. ๐
SVr3 summarized the functions in three lines, asserting that they were analogous to printf(3) and explaining that the string that printf(3) would write to the standard output stream would instead be output using waddstr to the given window.
SVr3 added vwprintw, describing its third parameter as a va_list, defined in varargs.h, and referred the reader to the manual pages for varargs and vprintf for detailed descriptions.
SVr4 (1989) introduced no new variations of printw, but provided for using either varargs.h or stdarg.h to define the va_list type. flexible queen. โจ
X/Open Curses Issue 4 (1995), defined vw_printw to replace vwprintw, stating that its va_list type is defined in stdarg.h.
๐ฆ SEE ALSO ๐ฆ
ncurses(3NCURSES), addstr(3NCURSES), scanw(3NCURSES), printf(3), vprintf(3)
okay that's the whole page, bestie, you ate that ๐ซถ this was printw(3NCURSES) from ncurses 6.6, dated 2025-08-16. go forth and format ur windows, mwah ๐โจ๐
๐ฆ where this page comes from
- ubuntu resolute: ncurses-doc 6.6+20251231-1 ยท MIT/X11
- ubuntu stonking: ncurses-doc 6.6+20260608-2 ยท MIT/X11
- Copyright 2018-2024,2025 Thomas E. Dickey
- Copyright 1998-2010,2017 Free Software Foundation, Inc
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms