C equivalent to fstream’s peek

fgetc+ungetc. Maybe something like this:

int fpeek(FILE *stream)
{
    int c;

    c = fgetc(stream);
    ungetc(c, stream);

    return c;
}

Leave a Comment