How to use the standard C language escape sequences in printf() in C

1 Answer

0 votes
#include <stdio.h> 
 
int main(int argc, char **argv)
{
    // standard C language escape sequences.
    
    printf("\a Bell (beep) \n"); //  \a Bell (“beep!”)
    printf("\b Backspace, non-erasing \n"); // \b Backspace, non-erasing
    printf("\f Form feed or clear the screen \n"); // \f Form feed or clear the screen
    printf("\n new line \n"); // \n Newline
    printf("\r Carriage return \n"); // \r Carriage return
    printf("\t Tab \n"); // \t Tab
    printf("\v Vertical tab \n"); // \v Vertical tab
    printf("\\ Backslash character \n"); // \\ Backslash character
    printf("\? Question mark \n"); // \? Question mark
    printf("\' Single quote \n"); // \' Single quote
    printf("\" Double quote \n"); //  \" Double quote
    printf("\x65 Hexadecimal character code nn \n"); // \xnn Hexadecimal character code nn
    printf("\022 Octal character code nn \n"); // \onn Octal character code nn
    printf("\22 Octal character code nn \n"); // \nn Octal character code nn    
    
    return 0;
}

/*
run:

 Bell (beep)
 Backspace, non-erasing
♀ Form feed or clear the screen

 new line
 Carriage return
         Tab
♂ Vertical tab
\ Backslash character
? Question mark
' Single quote
" Double quote
e Hexadecimal character code nn
↕ Octal character code nn
↕ Octal character code nn

*/


answered Apr 10, 2015 by avibootz
edited Apr 10, 2015 by avibootz

Related questions

2 answers 136 views
2 answers 231 views
1 answer 116 views
1 answer 318 views
1 answer 130 views
1 answer 154 views
154 views asked Dec 19, 2023 by avibootz
...