addstr(3NCURSES)
π addstr β bestie's guide to yeeting a string into a window β¨
okay so this is from the ncurses manual, section 3, and it's literally all about the addstr girlies. library calls, no cap. π
πΈ NAME πΈ
addstr, waddstr, mvaddstr, mvwaddstr, addnstr, waddnstr, mvaddnstr, mvwaddnstr β they add a string to a curses window and then the cursor moves on with its life, main character behavior honestly π¦
β¨ SYNOPSIS β¨
#include <curses.h>
int addstr(const char * str);
int waddstr(WINDOW * win, const char * str);
int mvaddstr(int y, int x, const char * str);
int mvwaddstr(WINDOW * win, int y, int x, const char * str);
int addnstr(const char * str, int n);
int waddnstr(WINDOW * win, const char * str, int n);
int mvaddnstr(int y, int x, const char * str, int n);
int mvwaddnstr(WINDOW * win, int y, int x, const char * str, int n);
π«Ά DESCRIPTION π«Ά
so waddstr writes the characters of the (null-terminated) string str into the window win, and it does it as if it were calling waddch(3NCURSES) for every single char in str. one by one. devoted. π
waddnstr is the same vibe but it writes at most n characters. and if n is -1? then waddnstr just writes the whole entire string, no restraint, iconic. π
and if you wanna know about the variants of these functions, that's ncurses(3NCURSES)'s whole job, she explains it. β¨
π RETURN VALUE π
these functions hand you back OK when it works and ERR when it does not. that's it, that's the whole range. π
in ncurses, these functions fail if:
- the curses screen has not been initialized π
stris a null pointer- (for the functions that take a
WINDOWpointer argument)winis a null pointer - an internal
waddch(3NCURSES)call returnsERR
and the ones prefixed with βmvβ do a cursor movement first, and they fail if the position (y, x) is outside the window boundaries. like bestie you cannot be somewhere you cannot be. π
π NOTES π
all of these functions except waddnstr may be implemented as macros. iykyk. π§
π PORTABILITY π
X/Open Curses Issue 4 describes these functions. and it specifies no error conditions for them. none. zero. wild.
SVr4 describes a successful return value only as βan integer value other than ERRβ. that's the whole description. so unserious of them. π
β HISTORY β
4BSD (1980) introduced waddstr along with its variants, and the variants were defined as macros.
SVr3.1 (1987) added waddnstr (and its variants) and redefined waddstr as a macro wrapping it. glow-up era fr fr. β¨
π SEE ALSO π
addwstr(3NCURSES)β describes comparable functions of the ncurses library in its wide-character configuration (ncursesw). πncurses(3NCURSES)addch(3NCURSES)addchstr(3NCURSES)
ok that's the whole page bestie, go forth and addstr responsibly π«Ά
ncurses 6.6 πΈ 2025-10-20 πΈ addstr(3NCURSES) β mwah, take care of her π
π¦ 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 2019-2024,2025 Thomas E. Dickey
- Copyright 1998-2012,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