转载自:http://www.jishuziyuan.com/archive/sinekary/7925378.html
每次想查某个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
int printf(const char *format, ...);
int fprintf(FILE *stream, const char *format, ...);
如果直接:
$ man printf
则默认显示的是第1条:可执行程序或shell命令
1 Executable programs or shell commands