/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program that inserts a character into the
buffer of a file then reads it and displays it. */
#include <stdio.h>

int main() {
    char c;
    FILE *stream;
   
    if((stream = fopen("ungetc.c", "r")) != NULL) {
        c = fgetc(stream);
        printf("The character pulled from the file is: %c\n", c);
        c = fgetc(stream);
        printf("The character pulled from the file is: %c\n", c);
        c = ungetc(c,stream);
        printf("ungetc(c,stream) = %c\n", c);
        c = fgetc(stream);
        printf("The character pulled from the file is: %c\n", c);
    }
    else
        printf("Error in opening file!\n");
    fclose(stream);
    return 0;
}

