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 πŸ™ˆ
  • str is a null pointer
  • (for the functions that take a WINDOW pointer argument) win is a null pointer
  • an internal waddch(3NCURSES) call returns ERR

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