C Backslash Characters : Meaning



Backslash Characters : Properties

You need to learn What is Backslash Character in C Programming.

  1. Although it consists of two characters, it represents single character.
  2. Each escape sequence has unique ASCII value.
  3. Each and Every combination starts with back slash()
  4. They are non-printable characters.
  5. It can also be expressed in terms of octal digits or hexadecimal sequence.
  6. Escape sequence in character constants and string literals are replaced by their equivalent and then adjacent string literals are concatenated
  7. Escape Sequences are preprocessed by Preprocessor.

1. Tab : ‘\t’ Character

  • It is Horizontal Tab
  • Takes Control 8 spaces ahead in Borland CC++ 3.0 Compiler
#include<stdio.h>

int main()
{
printf("Hello\t");
return(0);
}

Cursor Position After Execution of Printf :

Hello        _

2. New Line Character : ‘\n’ Character

  • It is New Line Character
  • Takes Control to new Line
#include<stdio.h>

int main()
{
printf("Hello\n");
return(0);
}

Cursor Position After Printf :

Hello
_

3. Backslash : ‘\b’ Character

  • It is Backslash Character
  • Takes Control one position back
#include<stdio.h>

int main()
{
printf("Hello\b");
return(0);
}

Cursor Position :

Hell_

[box]Note : on ‘o’ character from Word Hello[/box]

4. Carriage Return : ‘\r’ Character

  • It is Carriage Return Character
  • Takes Control to First Position in the Line
printf("Hello\r");

Cursor Position :

[box]Note : Cursor on ‘H’ character from Word Hello[/box]

_allo

4. Audible Return : ‘\a’ Character

  • It is audible Return Character
  • Beeps Sound
printf("Hello\a");

What will happen ?

Hello  

[box]After hello System Sound Beep will be started.[/box]