inchstr(3NCURSES)
π inchstr, inchnstr, winchstr, winchnstr, mvinchstr, mvinchnstr, mvwinchstr, mvwinchnstr β a.k.a. the get a curses character string from a window girlies π
okay so bestie, we're deep in the 3NCURSES manual, library calls section, and this is the one where you grab a whole lil curses character string out of a window. eight functions, one vibe. let's get into it π¦
β¨ NAME β¨
inchstr, inchnstr, winchstr, winchnstr, mvinchstr, mvinchnstr, mvwinchstr, mvwinchnstr β get a curses character string from a window. that's the whole job, and they do it flawlessly π
πΈ SYNOPSIS πΈ
#include <curses.h>
int inchstr(chtype * chstr);
int inchnstr(chtype * chstr, int n);
int winchstr(WINDOW * win, chtype * chstr);
int winchnstr(WINDOW * win, chtype * chstr, int n);
int mvinchstr(int y, int x, chtype * chstr);
int mvinchnstr(int y, int x, chtype * chstr, int n);
int mvwinchstr(WINDOW * win, int y, int x, chtype * chstr);
int mvwinchnstr(WINDOW * win, int y, int x, chtype * chstr, int n);
like, eight whole signatures, all cute, all yours π
π«Ά DESCRIPTION π«Ά
so winchstr extracts a curses character string from a curses window win, starting at the cursor and stopping at the end of the line, and stores it in chstr, terminating it with a null curses character. iconic behavior honestly.
winchnstr does the same thing, but copies at most n curses characters from win. and here's the plot twist: a negative n implies no limit β winchnstr then works like winchstr. no cap. π«£
ncurses(3NCURSES) describes the variants of these functions, so if you're nosy (same) go read that one too.
π RETURN VALUE π
these functions return OK on success and ERR on failure. simple as that, periodt.
in ncurses, these functions fail if:
- the curses screen has not been initialized,
- (for functions taking a
WINDOWpointer argument)winis a null pointer, or chstris a null pointer.
and the ones prefixed with βmvβ first perform cursor movement, and they fail if the position (y, x) is outside the window boundaries. rude, but fair. π
π NOTES π
all of these functions except winchnstr may be implemented as macros. so like, don't be weird about taking their address or whatever, iykyk.
π¨ okay this one matters, bestie: reading a line that overflows the array pointed to bychstrand its variants causes undefined results. instead, use the n-infixed functions with a positivenargument no larger than the size of the buffer backingchstr. pls pls pls do this, we are not trying to summon demons today π₯
π§ EXTENSIONS π§
inchnstr, winchnstr, mvinchnstr, and mvwinchnstr's acceptance of negative n values is an ncurses extension. so like, it's a glow-up that's ours specifically π
π¦ PORTABILITY π¦
applications employing ncurses extensions should condition their use on the visibility of the NCURSES_VERSION preprocessor macro. translation: vibe check your environment first, girlie.
X/Open Curses Issue 4 describes these functions. it specifies no error conditions for them. it characterizes the strings stored by these functions as containing βat most n elementsβ from a window, but does not specify whether the string stored by these functions is null-terminated. the ambiguity is giving mystery novel π
SVr4 does not document whether it null-terminates the curses character string it stores in chstr, and does not document whether a trailing null curses character counts toward the length limit n. so many unanswered questions, honestly same.
SVr4 describes a successful return value only as βan integer value other than ERRβ. iconic vagueness β¨
π HISTORY π
SVr3.1 (1987) introduced these functions. so they've been serving looks since the 80s, no big deal π
π₯ SEE ALSO π₯
in_wchstr(3NCURSES) describes comparable functions of the ncurses library in its wide-character configuration (ncursesw). that's the wide-character girlies, they're slaying over there too.
ncurses(3NCURSES), inch(3NCURSES), inwstr(3NCURSES) β go read them, bestie, knowledge is free and it's so cute π
and that's the whole page fr fr π this was ncurses 6.6, dated 2025-10-20, straight from the inchstr(3NCURSES) page β mwah, go forth and read your character strings responsibly, ily, bye ππΈ
π¦ 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