> 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/locale/digittoint.3.md).

# digittoint.3

`digittoint` — 将数字字符转换为其整数值

## 名称

`digittoint`, `digittoint_l`

## 库

Lb libc

## 概要

`#include <ctype.h>`

`Ft int Fn digittoint int c Ft int Fn digittoint_l int c locale_t loc`

## 描述

`digittoint` 和 `digittoint_l` 函数将数字字符转换为对应的整数值。该字符可以是任何十进制数字或十六进制数字。对于十六进制字符，其大小写不影响数值。

`digittoint_l` 函数接受一个显式的 locale 参数，而 `digittoint` 函数使用当前的全局或每线程 locale。

## 返回值

`digittoint` 和 `digittoint_l` 函数始终返回 0 到 15 范围内的整数。若给定字符不是由 [isxdigit(3)](/man/locale/isxdigit.3.md) 或 isxdigit\_l(3) 定义的数字，函数将返回 0。

## 参见

[ctype(3)](/man/locale/ctype.3.md), [ctype\_l(3)](/man/locale/ctype_l.3.md), [isdigit(3)](/man/locale/isdigit.3.md), isdigit\_l(3), [isxdigit(3)](/man/locale/isxdigit.3.md), isxdigit\_l(3), [xlocale(3)](/man/locale/xlocale.3.md)


---

# 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/locale/digittoint.3.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.
