character_count(+Stream, -Count)

Obtains the total number of characters either input from or output to the open stream Stream and unifies it with Count.


Stream stream_object
a valid open Prolog stream
Count integer
the resulting character count of the stream


A freshly opened stream has a character count of 0. When a character is input from or output to a non-tty Prolog stream, the character count of the Prolog stream is increased by one. Character count for a tty stream reflects the total character input from or output to the tty since the tty is opened to any stream. See ref-iou-sos-spt, for details on the use of this predicate on a stream that is directed to the user's terminal.

A nl/[0,1] operation also increases the character count of a stream by one unless the line border code (end_of_line option in open/4) is less than 0.


Stream errors (see ref-iou-sfh-est).

See Also

line_count/2, line_position/2, stream_position/[2,3]. ref-iou