Anthony Anthony - 1 year ago 191
C Question

C equivalent to fstream's peek

I know in C++, you're able to peek at the next character by using:


How would I go about this when trying to "peek" at the next character of a file in C?

Answer Source

fgetc+ungetc. Maybe something like this:

int fpeek(FILE *stream)
    int c;

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

    return c;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download