1 04/15/88 "SCATTER" EXAMPLE
2
3 /*
4 * SCATTER. This program takes the first
5 * 20 lines from the standard
6 * input and displays them on the
7 * VDU screen, in a random manner.
8 */
9
10 #include <curses.h>
11
12 #define MAXLINES 120
13 #define MAXCOLS 160
14 char sMAXLINES MAXCOLS; /* Screen Array */
15
16
17 long time;
18
19 main
20
21 int row=0col=0;
22 char c;
23 int char_count=0;
24 char bufBUFSIZ;
25 int i=0j=0;
26
27 for row=0; row<MAXLINES; row++
28 for col=0; col<MAXCOLS; col++
29 srowcol= 0;
30
31
32 row = 0;
33
34 /* Read screen in */
35
36 printf "Begin entering a screen ending with EOF or by
37 entering 20 lines\n";
38 while fgets&srow0MAXCOLSstdin != NULL && row < 20
39
40 for i=0;i<MAXCOLS;i++
41 if srowi == 0 break;
42 if srowi != ' ' char_count++;
43
44 row++;
45
46
47
48 srand timeNULL;
49
50 for i=0;char_count>0;i++
51 for j=0;j<MAXCOLS;j++
52 if sij != ' ' &&
53 sij != 0
54
55 row=rand % LINES;
56 col=rand>>2 % COLS;
57
58 moverowcol;
59 addch sij;
60 char_count--;
61
62
63 refresh;
64
65
66
67
68 echo;
69 endwin;
70 exit0;
71
72