> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man9/hexdump.9.md).

# hexdump.9

`hexdump` — 以十六进制形式将字节块转储到控制台

## 名称

`hexdump`

## 概要

```c
#include <sys/systm.h>
```

```c
void
hexdump(void *ptr, int length, const char *hdr, int flags)
```

## 描述

`hexdump` 函数以十六进制形式将字节数组打印到控制台，如果可能，还会打印字节的 ASCII 表示。默认情况下，每行输出以偏移计数开始，后跟 16 个十六进制值，再后跟 16 个 ASCII 字符。

**位 0-7** 每行显示字节数的整数值。值为 0 表示使用默认值 16。

**位 8-15** 用作十六进制输出分隔符的字符 ASCII 值。值为 0 表示使用默认值 32（ASCII 空格）。

**`HD_OMIT_COUNT`** 不在每行开头打印偏移列。

**`HD_OMIT_HEX`** 不在每行打印十六进制值。

**`HD_OMIT_CHARS`** 不在每行打印字符值。

**`ptr`** 指向要打印的字节数组的指针。不需要 `NUL` 终止。

**`length`** 要打印的字节数。

**`hdr`** 指向 `NUL` 终止字符串的指针，将前置于每行输出。值为 `NULL` 表示不打印标题。

**`flags`** 用于控制输出格式的标志。

## 参见

[ascii(7)](/man/man7/ascii.7.md)

## 作者

本手册页由 Scott Long 编写。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man9/hexdump.9.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
