man查看庫函數語法和所在頭文件

每次想查某個C庫函數的文件時,總是上網搜,然後在博客裏看到。有是還得看好幾篇,才找到。

這不是辦法呀,window有MSDN,linux有MAN,怎麼不去用呢?


1. 查看man(manual)手冊說明,看,man既是動詞,又是名詞,它還是形容詞(他好man哦)

$ man man

       The table below shows the section numbers of the manual followed by the types of pages they contain.

       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), e.g. man(7), groff(7)
       8   System administration commands (usually only for root)
       9   Kernel routines [Non standard]

可以看到,第3條是顯示庫函數的手冊。


2. 查看printf頭文件

$ man 3 printf

查看格式化說明符,可以搜索specifier

   The conversion specifier
       A character that specifies the type of conversion to be applied.  The conversion specifiers and their meanings are:

       d, i   The  int  argument is converted to signed decimal notation.  The precision, if any, gives the minimum number of digits that must appear; if the converted value
              requires fewer digits, it is padded on the left with zeros.  The default precision is 1.  When 0 is printed with an explicit precision 0, the output is empty.

       o, u, x, X
              The unsigned int argument is converted to unsigned octal (o), unsigned decimal (u), or unsigned hexadecimal (x and X) notation.  The letters  abcdef  are  used
              for x conversions; the letters ABCDEF are used for X conversions.  The precision, if any, gives the minimum number of digits that must appear; if the converted
              value requires fewer digits, it is padded on the left with zeros.  The default precision is 1.  When 0 is printed with an explicit precision 0, the  output  is
              empty.

查看所在頭文件,就在開頭SYNOPSIS標題下

PRINTF(3)                                                                 Linux Programmer's Manual                                                                 PRINTF(3)

NAME
       printf, fprintf, sprintf, snprintf, vprintf, vfprintf, vsprintf, vsnprintf - formatted output conversion

SYNOPSIS
       #include <stdio.h>

       int printf(const char *format, ...);
       int fprintf(FILE *stream, const char *format, ...);

如果直接:

$ man printf

則默認顯示的是第1條:可執行程序或shell命令

1 Executable programs or shell commands

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章