Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ungetc(3S) — GL1 W2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fseek(3S)

getc(3S)

setbuf(3S)

UNGETC(3S)  —  Silicon Graphics

NAME

ungetc − push character back into input stream

SYNOPSIS

#include <stdio.h>

int ungetc (c, stream)
char c;
FILE ∗stream;

DESCRIPTION

Ungetc inserts the character c into the buffer associated with an input stream. That character, c, will be returned by the next getc call on that stream. Ungetc returns c, and leaves the file stream unchanged. 

One character of pushback is guaranteed provided something has been read from the stream and the stream is actually buffered. 

If c equals EOF, ungetc does nothing to the buffer and returns EOF. 

Fseek(3S) erases all memory of inserted characters.

SEE ALSO

fseek(3S), getc(3S), setbuf(3S). 

DIAGNOSTICS

In order that ungetc perform correctly, a read statement must have been performed prior to the call of the ungetc function.  Ungetc returns EOF if it can’t insert the character.  In the case that stream is stdin, ungetc will allow exactly one character to be pushed back onto the buffer without a previous read statement. 

Version 2.1  —  January 02, 1985

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026