summaryrefslogtreecommitdiff
path: root/userland/libc/stdio/ungetc.c
blob: 18e5a21b13a1fd4c3546dde3db25879011d02986 (plain)
1
2
3
4
5
6
7
8
9
10
11
#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;
}