0

I need to erase a printed character in a new line from the end. That is if the statement is printf("C++") I need to erase those 2 "++" printed and get the output "C".

 printf("hello"); printf("\rbye"); 

Using the above escape sequence '\r', replaces it only from the printed line beginning to get the output 'byelo', how to do it from the end to get 'hebye'?

1
  • 1
    ncurses is a library that provides extensive cursor control useful for console applications. Commented Sep 19, 2015 at 16:13

1 Answer 1

1

You can use the backspace ASCII character:

printf("hello"); printf("\b"); 

Result:

hell 

UPD: see also this answer

Sign up to request clarification or add additional context in comments.

1 Comment

It actually is implementation specific. The standard does not guarantee this behaviour (try this when redirecting the text to a printer).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.