Source Code File 02-07_yourname
02-07_yourname.c
#include <ncurses.h> int main() { char first[16]; char last[16]; initscr(); addstr("What is your first name? "); refresh(); getnstr(first,15); addstr("What is your last name? "); refresh(); getnstr(last,15); printw("Pleased to meet you, %s %s!",first,last); refresh(); getch(); endwin(); return 0; }
Output Screenshot
Notes
* The second argument for getnstr() must be one less than the buffer size. This difference accounts for the null character, \0
, at the end of a string.
Copyright © 1997-2025 by QPBC.
All rights reserved