\ c escape sequence specified in man but not specified in C

I am currently studying C, if this question seems easy or newbie, then you know why.

Reading the man page for printf. I found \ c as an escape sequence. Description

does not produce any additional result

I have never seen or heard about \ c until this moment. Therefore, I decided to try in a simple world program:

printf("\nHello World\n\n\c"); 

As a result, gcc gives me this warning:

warning: unknown escape sequence: '\ c' [enabled by default]

This sounds strange to me, so I continued to research: I went to Wikipedia and c was not listed as an escape sequence ... So I tried to search the network, and here is the stack overflow. I found very few references to \ c (actually two), as discussed in this section, and this one (I think the latter is not related to C, but it seems that we are talking about "the same \ c ", reading the description above) . Can someone help me understand this thing?

+5
source share
1 answer

You are not reading the correct manual page. What you are looking for is: man 1 printf , which refers to the printf shell command, not the standard printf function.

Using:

  man 3 printf 

to read about the library function C. \c not in C and therefore printf(3) not recognized.

printf(1) you are looking at works as documented.

 $ /usr/bin/printf "ABC\chi" 

gives:

 ABC 

Please note that the Linux manual pages in general may also have additional non-standard extensions (related to Linux or glibc) and POSIX extensions, etc. Custom extensions are usually documented as such, but are easy to skip. Therefore, if you are looking for what standard C says, you should look at standard C. Here is an online project .

If you're curious that the number passed to man is the section number. 3 corresponds to library function. You can find information: man man . Here is a summary of the sections:

  1 Executable programs or shell commands 2 System calls (functions provided by the kernel) 3 Library calls (functions within program libraries) 4 Special files (usually found in /dev) 5 File formats and conventions eg /etc/passwd 6 Games 7 Miscellaneous (including macro packages and conventions), eg man(7), groff(7) 8 System administration commands (usually only for root) 9 Kernel routines [Non standard] 
+6
source

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


All Articles