Source Code File 06-04_text4
06-04_text4.c
#include <ncurses.h> int main() { char text1[] = "This is the first line\n"; char text2[] = "Line two here\n"; char text3[] = "The third line\n"; char text4[] = "Fourth line here\n"; char text5[] = "And the fifth line\n"; initscr(); addstr(text1); addstr(text3); addstr(text5); refresh(); getch(); move(1,0); /* Second line/row */ insertln(); /* add a blank line */ move(3,0); /* Fourth row */ insertln(); refresh(); getch(); move(1,0); /* Second row */ addstr(text2); move(3,0); /* Fourth row */ addstr(text4); refresh(); getch(); endwin(); return(0); }
Output Screenshot
(Click to cycle through screenshots.)
Notes
* The solution is rather easy when compared with 06-03_text3.c: Insert the second line and add the second (well, fourth) string.
* You must account for the proper location for the fourth row.
* You must also update the cursor's location between the separate calls to insertln() and addstr().
Copyright © 1997-2024 by QPBC.
All rights reserved