In a C program under Linux and
if (getch() =! ERR)
// store the character into an array
if (getch() == 10)
// terminate the string and print it on screen
If the OP's program used the
keypad() function, then left-cursor (arrow) and the erase key would have the same effect.
getnstr does not support inline editing (moving the cursor within the line). (Incidentally, other implementations of curses do nothing with cursor-keys).
As an example of a program which does support inline-editing,
dialog is useful (it works with UTF-8). On the other hand, because it stores the responses as a plain character string, it is more complicated, say, than something explicitly written to use
cdk does not handle UTF-8.
ncurses does not provide a more interesting function because:
Recently there was a related question (for blocking I/O) in ncurses, print and contemporary acquire strings (again,
dialog does that).