working through C version of scanw example (7.4)

This commit is contained in:
Dan Buch 2009-11-21 11:00:10 -05:00
parent b13831dc92
commit 791b8d227c

View File

@ -1,16 +1,15 @@
#include <ncurses.h> /* ncurses.h includes stdio.h */ #include <ncurses.h>
#include <string.h> #include <string.h>
int main() int main()
{ {
char mesg[]="Enter a string: "; /* message to be appeared on the screen */ char * mesg = "Enter a string: ";
char str[80]; char str[80];
int row,col; /* to store the number of rows and * int row, col;
* the number of colums of the screen */
initscr(); /* start the curses mode */ initscr();
getmaxyx(stdscr,row,col); /* get the number of rows and columns */ getmaxyx(stdscr, row, col);
mvprintw(row/2,(col-strlen(mesg))/2,"%s",mesg); mvprintw(row / 2, (col - strlen(mesg)) / 2, "%s", mesg);
/* print the message at the center of the screen */
getstr(str); getstr(str);
mvprintw(LINES - 2, 0, "You Entered: %s", str); mvprintw(LINES - 2, 0, "You Entered: %s", str);
getch(); getch();