I'm making a simple 'game' with ncurses in C, and for name input I use getnstr
. I have the following code:
printw("What is your name? ");
char name[10];
int namelen = getnstr(name, 10);
Now, I want to allow max 10 characters, and I want to use the length of the name for the border columns. However, namelen
is 0 for some reason (I thought getnstr
returned the length).
How can I get the correct length of the name? So if I insert Josh as name I get 4. sizeof(name)
returns 10 so it's no use.