Reputation: 359
How can i clear the current line or any line in the console using c ?
Enter a number (waiting for the user input):
After the user has input something the line is cleared and another line is printed out
You've just entered the number 4
How can I achieve this in c ?
Upvotes: 0
Views: 726
Reputation: 3837
Clearing any line is not possible in C. For this level of control in the terminal, you'd need to use a library like ncurses.
The closest you can get in pure C is by first printing the carriage return caracter (\r
) and then printing over the previously printed text. You could print spaces to "clear" the text. However:
Upvotes: 1