summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2017-01-03 12:24:57 -0700
committermo khan <mo@mokhan.ca>2017-01-03 12:24:57 -0700
commitc1b827d1210405f309fd9bac3275f536beea282d (patch)
tree215ef248efc2025b0364729861318e9a9931f32b
parentf9898440349580c95603a4e691bdd9600712b301 (diff)
add printw example.main
-rw-r--r--src/main.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 24ad982..e82e5fc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,4 +1,5 @@
#include <ncurses.h>
+#include <string.h>
void hello_world() {
initscr();
@@ -8,8 +9,22 @@ void hello_world() {
endwin();
}
+void printw_example(){
+ char mesg[]="Just a string";
+ int row,col;
+ initscr();
+ getmaxyx(stdscr,row,col);
+ mvprintw(row/2, (col-strlen(mesg))/2, "%s", mesg);
+ mvprintw(row-2, 0, "this screen has %d rows and %d columns\n",row,col);
+ printw("Try resizing your window (if possible) and then run this program again");
+ refresh();
+ getch();
+ endwin();
+}
+
int main(int argc, const char *argv[])
{
hello_world();
+ printw_example();
return 0;
}