---
name: "Scanf.Scanning"
section: "3o"
platform: "linux"
package: "ocaml"
version: "5.5.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/Scanf.Scanning"
---

# Scanf.Scanning(3o)

no description

## NAME

Scanf.Scanning - no description

## Module

Module   Scanf.Scanning

## Documentation

Module **Scanning**\
  :  **sig end**

*type in\_channel*

The notion of input channel for the  **Scanf** module: those channels provide all the machinery necessary to read from any source of characters, including a  **in\_channel** value. A Scanf.Scanning.in\_channel value is also called a formatted input channel or equivalently a scanning buffer. The type  **Scanf.Scanning.scanbuf** below is an alias for  **Scanning.in\_channel** . Note that a  **Scanning.in\_channel** is not concurrency-safe: concurrent use may produce arbitrary values or exceptions.

**Since** 3.12

*type scanbuf* =  **in\_channel**

The type of scanning buffers. A scanning buffer is the source from which a formatted input function gets characters. The scanning buffer holds the current state of the scan, plus a function to get the next char from the input, and a token buffer to store the string matched so far.

Note: a scanning action may often require to examine one character in advance; when this 'lookahead' character does not belong to the token read, it is stored back in the scanning buffer and becomes the next character yet to be read.

*val stdin* :  **in\_channel**

The standard input notion for the  **Scanf** module. **Scanning.stdin** is the  **Scanf.Scanning.in\_channel** formatted input channel attached to  **stdin** .

Note: in the interactive system, when input is read from **stdin** , the newline character that triggers evaluation is part of the input; thus, the scanning specifications must properly skip this additional newline character (for instance, simply add a  **'\\n'** as the last character of the format string).

**Since** 3.12

*type file\_name* =  **string**

A convenient alias to designate a file name.

**Since** 4.00

*val open\_in* :  **file\_name -\> in\_channel**

**Scanning.open\_in fname** returns a  **Scanf.Scanning.in\_channel** formatted input channel for bufferized reading in text mode from file  **fname** .

Note: **open\_in** returns a formatted input channel that efficiently reads characters in large chunks; in contrast,  **from\_channel** below returns formatted input channels that must read one character at a time, leading to a much slower scanning rate.

**Since** 3.12

*val open\_in\_bin* :  **file\_name -\> in\_channel**

**Scanning.open\_in\_bin fname** returns a  **Scanf.Scanning.in\_channel** formatted input channel for bufferized reading in binary mode from file  **fname** .

**Since** 3.12

*val close\_in* :  **in\_channel -\> unit**

Closes the  **in\_channel** associated with the given **Scanf.Scanning.in\_channel** formatted input channel.

**Since** 3.12

*val from\_file* :  **file\_name -\> in\_channel**

An alias for  **Scanf.Scanning.open\_in** above.

*val from\_file\_bin* :  **string -\> in\_channel**

An alias for  **Scanf.Scanning.open\_in\_bin** above.

*val from\_string* :  **string -\> in\_channel**

**Scanning.from\_string s** returns a  **Scanf.Scanning.in\_channel** formatted input channel which reads from the given string. Reading starts from the first character in the string. The end-of-input condition is set when the end of the string is reached.

*val from\_function* :  **(unit -\> char) -\> in\_channel**

**Scanning.from\_function f** returns a  **Scanf.Scanning.in\_channel** formatted input channel with the given function as its reading method.

When scanning needs one more character, the given function is called.

When the function has no more character to provide, it must signal an end-of-input condition by raising the exception  **End\_of\_file** .

*val from\_channel* :  **in\_channel -\> in\_channel**

**Scanning.from\_channel ic** returns a  **Scanf.Scanning.in\_channel** formatted input channel which reads from the regular  **in\_channel** input channel  **ic** argument. Reading starts at current reading position of  **ic** .

*val end\_of\_input* :  **in\_channel -\> bool**

**Scanning.end\_of\_input ic** tests the end-of-input condition of the given **Scanf.Scanning.in\_channel** formatted input channel.

*val beginning\_of\_input* :  **in\_channel -\> bool**

**Scanning.beginning\_of\_input ic** tests the beginning of input condition of the given  **Scanf.Scanning.in\_channel** formatted input channel.

*val name\_of\_input* :  **in\_channel -\> string**

**Scanning.name\_of\_input ic** returns the name of the character source for the given  **Scanf.Scanning.in\_channel** formatted input channel.

**Since** 3.09
