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
    ***[ncurses](https://www.google.com/?gws_rd=ssl#q=ncurses+tutorial)*** is a library that provides extensive cursor control useful for console applications. – ryyker Sep 19 '15 at 16:13

1 Answers1

1

You can use the backspace ASCII character:

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

Result:

hell

UPD: see also this answer

Community
  • 1
  • 1
Alexander Udalov
  • 31,429
  • 6
  • 80
  • 66