Why is the letter "D" missing from the output?
You will get everything you cout . It’s just that the terminal interprets '\b' as "go back one character" . Try redirecting the output to a file and examine it using the (hexadecimal) editor to see that all characters (including '\b' ) are there.
At first glance, you might think that the terminals print the output as it is. This is not true. Terminals change the way they behave when they encounter one of the terminal’s special escape sequences or characters. The symbol '\b' (= 0x08 = backspace) is one of them. More details can be found at http://ascii-table.com/ansi-escape-sequences.php . You can try to print some of them on the terminal and see how it changes colors, rewrite the current lines, etc. Etc. In fact, you can use these special sequences and characters to create complete graphical applications on the command line.
Note, however, that not with all programs, you can rely on the "redirect to a file" trick to find out which terminal escape sequences they write to stdout. Many programs detect whether they record a terminal or not, and accordingly adjust their use (or lack thereof) of terminal control sequences.
cout << ch1 << '\t' << ch2 << ch3; prints A , tab B , and then a newline.
cout << 'C' << '\t' << 'D' << '\b' << ch1 << ch3; displays the C tab D , then moves the cursor beyond D , prints A (this overwrites the D character), and then prints a newline character.
\b escape sequence that represents the backspace . It moves the cursor one step back.