---
name: "scan_ulong"
section: "3"
platform: "linux"
package: "libowfat-dev"
version: "0.32-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/scan_ulong"
---

# scan\_ulong(3)

parse an unsigned long integer in decimal ASCII representation

## NAME

scan\_ulong - parse an unsigned long integer in decimal ASCII representation

## SYNTAX

**#include \<libowfat/scan.h\>**

size\_t **scan\_ulong**(const char \**src*,unsigned long \**dest*);

## DESCRIPTION

scan\_ulong parses an unsigned long integer in decimal ASCII representation from *src* and writes the result into *dest*. It returns the number of bytes read from *src*.

Leading + or - or space (or anything outside of 0-9) is not accepted. The libc conventions of "023" for octal or "0x23" for hexadecimal are not supported.

scan\_ulong will abort the scan if the next character is not a digit, or if it is a digit but adding it to the number would lead to an integer overflow.

## RETURN VALUE

scan\_ulong returns the number of characters successfully scanned and processed from src.

## EXAMPLES

scan\_ulong("23",&i) -\> i=23, return 2

scan\_ulong("+23",&i) -\> return 0

scan\_ulong("-23",&i) -\> return 0

scan\_ulong(" 23",&i) -\> return 0

scan\_ulong("23,42",&i) -\> i=23, return 2

scan\_ulong("023",&i) -\> i=23, return 3

scan\_ulong("0x23",&i) -\> i=0, return 1

scan\_ulong("4294967296",&i") -\> i=429496729, return 9 // 32-bit system

## SEE ALSO

[scan\_xlong(3)](/scan_xlong/3.md), [scan\_8long(3)](/scan_8long/3.md), [fmt\_ulong(3)](/fmt_ulong/3.md)
