summaryrefslogtreecommitdiff
path: root/userland/libc/stdio/ungetc.c
blob: 3b93b70981cffffb31132536b84e2677dd7e1ef0 (plain)
1
2
3
4
5
6
7
8
9
10
#include <stdio.h>

int ungetc(int c, FILE *stream) {
  if (stream->has_buffered_char)
    return EOF;
  stream->buffered_char = c;
  stream->has_buffered_char = 1;
  fseek(stream, -1, SEEK_CUR);
  return c;
}