Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do \t and \b do?

Tags:

c

printf

I expect this simple line of code

printf("foo\b\tbar\n"); 

to replace "o" with "\t" and to produce the following output

fo     bar 

(assuming that tab stop occurs every 8 characters). On the contrary I get

foo    bar 

It seems that my shell interprets \b as "move the cursors one position back" and \t as "move cursor to the next tab stop". Is this behaviour specific to the shell in which I'm running the code? Should I expect different behaviour on different systems?

like image 787
cimere Avatar asked Dec 28 '11 15:12

cimere


People also ask

What do the T and B cells do?

T cells can wipe out infected or cancerous cells. They also direct the immune response by helping B lymphocytes to eliminate invading pathogens. B cells create antibodies. B lymphocytes, also called B cells, create a type of protein called an antibody.

How are T and B cells activated?

T and B cells are activated when they recognize small components of antigens, called epitopes, presented by APCs, illustrated in Figure 2. Figure 2. An antigen is a macromolecule that reacts with components of the immune system.

How do T and B lymphocytes recognize different antigens?

Lymphocytes can be further differentiated into B cells, T cells, and natural killer cells. While natural killer cells recognize general signals of immune stress such as inflammation, B and T cells recognize foreign antigens specifically via hypervariable B cell and T cell receptors (BCRs and TCRs).

How do T cells work in the immune system?

They can act as “killer cells”, attacking cells which have been infected with a virus or another kind of pathogen, or they can act as “helper cells” by supporting B cells to produce antibodies.


1 Answers

No, that's more or less what they're meant to do.

In C (and many other languages), you can insert hard-to-see/type characters using \ notation:

  • \a is alert/bell
  • \b is backspace/rubout
  • \n is newline
  • \r is carriage return (return to left margin)
  • \t is tab

You can also specify the octal value of any character using \0nnn, or the hexadecimal value of any character with \xnn.

  • EG: the ASCII value of _ is octal 137, hex 5f, so it can also be typed \0137 or \x5f, if your keyboard didn't have a _ key or something. This is more useful for control characters like NUL (\0) and ESC (\033)

As someone posted (then deleted their answer before I could +1 it), there are also some less-frequently-used ones:

  • \f is a form feed/new page (eject page from printer)
  • \v is a vertical tab (move down one line, on the same column)

On screens, \f usually works the same as \v, but on some printers/teletypes, it will go all the way to the next form/sheet of paper.

like image 153
BRPocock Avatar answered Sep 23 '22 13:09

BRPocock