Printf format parameter contains undefined escape character

#include <stdio.h> int main() { printf("Hello\c!\n"); return 0; } 

Exit: Helloc!

So, when \[some_undifined_symbol] appeared in the printf format printf , it just ignores \ ?

+2
source share
2 answers

\c not an escape sequence that is already defined, but it is better to avoid using it since it is reserved:

C99 ยง6.11.4 Escape sequences

Lowercase letters as escape sequences are reserved for future standardization. Other characters may be used in extensions.

+4
source

You have the following escape sequences defined for c :

  • \' single quote
  • \" double quote
  • \\ backslash
  • \0 null character
  • \a sound call
  • \b backspace
  • \f form feed - new page
  • \n line feed - new line
  • \r carriage return
  • \t horizontal tab
  • \v vertical tab
  • \nnn arbitrary octal value
  • \xnn arbitrary hex value
+1
source

Source: https://habr.com/ru/post/1241068/


All Articles