|
CS256 - Fundamentals of Structured Programming
| Displaying exercises/e8/solution/p1.c
#include <stdio.h>
#include <curses.h>
/**
* Complete the main function below. Make it print "Hello, world!" every other
* line starting from the upper left corner and moving to the right 2 columns
* for every new line, stop when you get to the bottom of the screen (LINES-1).
* Print a "Press any key to exit" message at the bottom left corner and wait
* for a keypress to quit the program.
*/
int main(void)
{
initscr();
clear();
int x = 0;
for(int y = 0; y < LINES-1; y+= 2, x+= 2) {
mvprintw(y,x,"Hello, world!");
}
mvprintw(LINES-1, 0, "Press any key to exit");
refresh();
getch();
endwin();
return 0;
}
|