Canul Podkopayeva wrote:
> /*
> * Hello, sorry to bother again with lame code but...
> * I get this code to build but it core dumps and gdb tells me that it
> sigvfault at waddch.
> * I have no idea on how to fix this.
First your arrays are numbered wrong. Use (0 ... 5) not (1...6) Next,
your wrefresh() statement(s) are not being executed the way they ought to
be because you've placed a semicolon after the "for" statement. Also, you
might want to add a "sleep(1)" statement after "wrefresh( win[i] )" in
the for loop to slow down the refresh rate for a better effect when the
program is run. See my additional comments below.
>
> */
>
> #include <stdio.h>
> #include <curses.h>
> #include <signal.h>
> #include <time.h>
> #include <stdlib.h>
>
> static void done(int sig);
>
> void main(void)
> {
> WINDOW *win[6];
> unsigned seed;
> int xer, yer, i;
> signal(SIGINT, done);
> initscr();
> nonl();
> noecho();
> keypad(stdscr, TRUE);
> cbreak();
> if(has_colors())
> {
> start_color();
> init_pair(1, COLOR_GREEN, COLOR_BLACK);
> init_pair(2, COLOR_RED, COLOR_BLACK);
> init_pair(3, COLOR_BLUE, COLOR_BLACK);
> }
> else
> fprintf(stderr, "This terminal can't support colors\n"), exit(0);
> seed = time((time_t *)0);
> srand(seed);
> for(i = 0; i < 6; ++i)
> win[i] = newwin(i, i, 2, 22);
/* Change these array indexes for these array references from the 1 ...
6, actually 1, ...5,5 range to 0 ... 5 range
>
> wattrset(win[1], COLOR_PAIR(1));
> wattrset(win[2], COLOR_PAIR(2));
> wattrset(win[3], COLOR_PAIR(3));
> wattrset(win[4], COLOR_PAIR(3));
> wattrset(win[5], COLOR_PAIR(2));
> wattrset(win[5], COLOR_PAIR(1));
/* Same changes need to be made here */
>
> waddch(win[1], 'C');
> waddch(win[2], 'a');
> waddch(win[3], 'n');
> waddch(win[4], 'u');
> waddch(win[5], 'l');
> waddch(win[6], 'y');
/* Watch your "for" loop here!!! I don't think that you want that colon
after your for statement. Remove it!!
Also, to slow down the effect of the program so that the eye can catch
the different letters being displayed onscreen in all the different
colours, unless you have a very slow processor, add a "sleep()"
statement!!In other words do this:
for (i = 0; i < 6; i++) {
wrefresh(win[i]);
sleep(1); /* pause for 1000ms */
}
*/
>
> for(i = 0; i < 6; i++);
> wrefresh(win[i]);
> done(0);
> }
>
>
> static void done(int sig)
> {
> if(sig == 4)
> printf("^C caught!\n"), endwin(), exit(0);
> endwin();
> puts(P_VERSION);
> }
>
>
> _________________________________________________________
--
email: [EMAIL PROTECTED]
Local mailserver , remote
Promote CURES, not wars on drugs!!