user3753834
user3753834

Reputation: 369

C - Is there a way to remove a mvwprintw from my window? (Ncurses)

I want my mvwprintw statement to disappear after a point in the code. I don't know how delete the print statement though. Is there a print function that can do it? I tried by creating another statement full of spaces thinking it would overlap the existing statement and it would look blank. I tried looking online but could not find anything. Please let me know if there is a way.

Upvotes: 0

Views: 619

Answers (2)

Simas
Simas

Reputation: 44158

You can clear the whole line by moving to the beginning of a line

move(3,0);

and then clearing the line

clrtoeol();

Upvotes: 1

user3753834
user3753834

Reputation: 369

I actually found a way, hopefully this helps someone with the same problem in the future. All you need to do is to add \rat the beginning of your statement and it will over wright anything previously in that spot.

mvwprintw(win2,3,16,"Hi.");
mvwprintw(win2,3,16,"\rPlease make your first move."); //overwrites the "Hi"
mvwprintw(win2,3,16,"\rPlease make your second move.");//overwrites the "Please make your first move"

Adding blank spaces into the print statement would erase your previous message.

Upvotes: 0

Related Questions