Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C How to return screen to normal after curses program ends

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

like image 953
user2661167 Avatar asked Nov 01 '13 10:11

user2661167


1 Answers

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

like image 78
dnk Avatar answered Sep 22 '22 02:09

dnk