get_char(?in_character) [ISO]

This built-in clause reads a single character from the current input stream, the stream is altered. The current input stream must be a text stream that was opened for reading. An in_character is a character or the atom 'end_of_file'.

see also: get_char/2 get_code/1 get_code/2 peek_char/1 peek_char/2 peek_code/1 peek_code/2 prolog I/O put_char/1 put_char/2 put_code/1 put_code/2 nl/0 nl/1

Example
get_char(A). Assume the current input stream has contents: q, w, r, ...
A is assigned the value q and the stream is left as: w, r, ...
get_char('a'). Assume the current input stream has contents: q, w, r, ...
get_char/1 fails, and a character was removed from the stream, the current input stream is left as: w, r, ...

 

Exceptions  
Char is neither a variable nor an in_character a type_error(in_character, Char) is thrown
current input stream is a binary stream a permission_error(input, binary_stream, InputStream) is thrown, the variable InputStream is assigned the stream which was used as the input stream
current input stream has properties end_of_stream(past) and eof_action(error) a permission_error(input, past_end_of_stream, InputStream) exception is thrown

 

 

info@trinc-prolog.com