Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > U


HP-UX 11i Version 3: February 2007

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index


ungetc() — push character back into input stream


#include <stdio.h>

int ungetc(int c, FILE *stream);

Obsolescent Interface

int ungetc_unlocked(int c, FILE *stream);


ungetc() inserts the character c (converted to an unsigned char) into the buffer associated with an input stream. That character, c, is returned by the next call to getc() (see getc(3S)) on that stream. A successful intervening call to a file positioning function with stream (fseek(), fsetpos(), or rewind()) erases all memory of the inserted characters.

ungetc() affects only the buffer associated with the input stream. It does not affect the contents of the file corresponding to stream.

One character of pushback is guaranteed.

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

Obsolescent Interface

ungetc_unlocked() pushes character back into input stream.


After ungetc() is applied to a stream, the stream becomes byte-oriented (see orientation(5)).


If successful, ungetc() and ungetc_unlocked() return c and clear the end-of-file indicator for the stream. ungetc() and ungetc_unlocked() return EOF if they cannot insert the character.


ungetc_unlocked() is an obsolescent interface supported only for compatibility with existing DCE applications. New multithreaded applications should use ungetc().


ungetc(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.