gigatron/rom/Archive/lcc/Libs/stdio/fgetc.c
2025-01-28 19:17:01 +03:00

18 lines
316 B
C

#include <errno.h>
#include <stdio.h>
int fgetc(FILE *stream)
{
if ((stream->_flags & _ioread) == 0) {
errno = -EBADF;
return EOF;
}
if (stream->_n == 0) {
int r = stream->_flush(0 /*dummy*/, stream); // Read new data
if (r < 0)
return r;
}
stream->_n--;
return *stream->_ptr++;
}