-
一、man手册的安装
在默认情况下,系统只安装第一册,其他的帮助信息一般需要用户自己手动安装,安装指令如下:
gec@ubuntu:~$ sudo apt install manpages
gec@ubuntu:~$ sudo apt install manpages-dev
-
二、man文档的前三册基本内容
1.可执行程序或Shell命令(默认已安装)
2.系统调用 (Linux内核自带的函数)
3.库函数 (外部的第三方函数)
-
三、man手册的查询
使用man手册查询命令、函数时,一般直接在man后面接上待查条目即可,
但有时候会遇到同一个待查询的条目存在于多个man分册的情况,
这就需要先罗列出该条目所在的分册信息,
然后再根据需要去选择帮助文档的序号。
1、查询单一分册的条目: gec@ubuntu:~$ man strcpy
2、查询存在于多个分册的条目:
先使用 -f 来查看有哪些分册包含了该条目
gec@ubuntu:~$ man -f printf
printf (1) - format and print data
printf (3) - print formatted output
根据需要,指定查询某一册帮助分册
gec@ubuntu:~$ man 3 printf
3.例子:
使用man手册,来查询一个strlen函数的使用方法
(1)、在ubuntu系统终端上敲命令:man -f strlen
(2)、man 3 strlen
(3)、如何使用一个函数??
a、函数的作用(NAME)
strlen - calculate the length of a string // 计算字符串的长度
b、函数的头文件(SYNOPSIS)
#include <string.h>
c、函数原型解析(DESCRIPTION)
size_t strlen(const char *s);
参数一:要计算长度的字符串变量
The strlen() function calculates the length of the string s, excluding the terminating null byte ('\0').
// 翻译:这个strlen函数会计算s这个字符串的长度,但是不包括结束符\0
d、函数的返回值(RETURN VALUE)
返回字符串的字节数(这个字符串有多少个字符)