Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - ungetc http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   ungetc

   Usage
   #include <stdio.h>
   int ungetc(int c,FILE *fp);

   Description
   Puts  character c back into the input stream fp, where it is  read  by
   the next input operation on the stream. If an fseek is done between an
   ungetc  and the next read, then the ungotten character is  lost.  Only
   one character may be put back between reads. EOF cannot be ungotten.

   Example
   #include <stdio.h>
   #include <ctype.h>
   main()
   {
   char ch;
   FILE *stream;
        stream = fopen("file.dat","r");
        while((ch = fgetc(stream)) != EOF)
        {
             if(isspace(ch))
                  break;
              ungetc(ch,stream);
              ch = fgetc(stream);
        }
        fclose(stream);
   }

   Return Value
   ungetc  returns  c if successful and returns an EOF if  the  character
   cannot be pushed back.


See Also: getc getchar putc putchar

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson