Question

I'm still new to C and ncurses. I was asked to do an assignment that involved making a multithreaded pong game. The game runs fine and ends with the correct lossing conditions but upon termination my terminal is all messed up. I get no echo, so I have to type stty echo to get that back, even then the terminal behaves strangely.

My end function is the following:

void wrap_up(){

    curs_set(1);
    clear();
    endwin();
    refresh();
}

Here is a screenshot. How do I fix it?

enter image description here

Était-ce utile?

La solution

Remove refresh after endwin. Calling refresh after endwin causes the program to go back into the curses mode.

Autres conseils

Well, it depends on how you want to implement it. To make it portable you might want to implement compiling directives to clear the screen depending on what OS you're working on.

E.g.:

void Refresh(){
#ifdef WIN_32_OS
  system("cls");
#elif LINUX_OS
  system("clear");
#else // (DOS, for example)
  system("Another command");
#endif
}

So in the compiling time you can use something like that:

bash2.2$ gcc -c -DLINUX_OS code.c -o code

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top