11.3.37 character_count/2


character_count(+Stream, -Count)

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



stream_object, must be ground

A valid open text stream



The resulting character count of the stream


A freshly opened text stream has a character count of 0. When a character is input from or output to a non-interactive Prolog stream, the character count of the Prolog stream is increased by one. Character count for an interactive stream reflects the total character input from or output to any interactive stream, i.e. all interactive streams share the same counter.

A nl/[0,1] operation also increases the character count of a stream by one.

The count is reset by set_stream_position/2.


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

See Also

byte_count/2, line_count/2, line_position/2, stream_position/2, set_stream_position/2, ref-iou-sfh.

Send feedback on this subject.