Escape Characters

   Sequence   Meaning
/aALERT (ANSI C)
/bBackspace
/fForm feed  
/nNewline
/rCarriage return
/tHorizontal tab
/vVertical tab
\\Backslash
\’Single quote

\”Double quote
\?Question mark
\0ooOctal value (o represents octal value)
\xhhHexadecimal value. (h represents a hexadecimal)
Escape Characters

Escape Characters:

  • They are special characters to represent actions.

Example:

 To give backspacing.

To go to the next line.

Making the terminal bell ring.

  • Escape actions must be closed within single quotation marks when assigned with a variable.
  • Char x = ‘\n’;
  • And then print the variable x to advance print or screen one line.
  • Given below are some of the escape characters generally used:

Some terms related to the above box. 

    Carriage return: another term for return.
  Form feed: It’s a term used for page   break.  

Format Specifiers:

  • Format specifiers are used when we display variables as output.
  • Format specifiers means specifying the type of format we are going to declare.
  • int sum = 89

printf(“The sum is %d\n”, sum);

We are using all the functions to display our output,

  • First, we enclosed sum and %d in parentheses.
  • Arguments are separated by commas.
  • We are using printf function to display the output.
  • And using escape characters.
  • The %d is the first argument which is recognised by printf to give output. The character will immediately follow the % sign to specify the value to be displayed.
#include<stdio.h>
#include<conio.h>
void main()
{
   int integerVar = 20;
  float floatingVar = 332.33;
 double doubleVar = 8.33e+11;
 char  charVar = ‘w’;


_Bool boolVar = 1; (Maybe 0 or 1 because it is binary format).

printf(“integerVar = %i\n” , integerVar);
printf(“floatingVar = %f\n” , floatingVar);
printf(“doubleVar = %e\n” , doubleVar);
prinf(“doubleVar = %g\n” , doubleVar);
printf(“charVar = %c\n” , charVar);

printf(“boolVar = %i\n” , boolVar);
getch();
return 0;

}
Input
Output

Command Line arguments

  • Passing data beyond the line during the program is been running.
  • We have two ways to handle this:
  • Requesting data from the user.
  • Supplying information when the program is executed. (command line arguments)
  • Every C program have main function which is the entry point of the program.
  • First argument is an integer value (argc) that specifies number of arguments typed in the command line.
  • Second argument is an array (argv)of character pointers.
Character Pointers: A pointer is a special memory location that can hold address of some other memory cell. So, a character pointer is a pointer that can point to any location holding character only. Since the content of any pointer is an address, size of all types of pointer (character, int, float, double) is 4.  
  • Example:
Output

Scroll to top