|
CS256 - Fundamentals of Structured Programming
| Displaying exercises/e9/solution/c2.c
#include "c.h"
/**
* Complete the main function to draw colored lines across the screen and down
* the screen. The horizontal lines should start on line 5 (0 based) with
* background color 0, the vertical lines should start on column 10 (0 based).
* Print the message "Press any key to exit" in at the bottom middle of the
* screen and then wait for a key-press.
*/
int main(void)
{
init_curses();
int color = 0;
for(int line = 5; line < 5+8; line++) {
for(int col = 0; col < COLS; col++) {
mvaddch(line,col,' ' | COLOR_PAIR(COLOR_WHITE*8+color));
}
color = (color + 1) % 8;
}
color=0;
for(int col = 10; col < 18; col++) {
for(int line = 0; line < LINES; line++) {
mvaddch(line,col,' ' | COLOR_PAIR(COLOR_WHITE*8+color));
}
color = (color + 1) % 8;
}
char mesg[] = "Press any key to exit";
mvprintw(LINES-1,COLS/2-strlen(mesg),mesg);
refresh();
getch();
leave_curses();
return 0;
}
|