Skip to content

Commit 54c29b0

Browse files
committed
putchar, getchar
1 parent 985d3b8 commit 54c29b0

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

libsrc/stdio/getchar.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "stdio.h"
2+
3+
#include "./_file.h"
4+
#undef getchar
5+
6+
int getchar(void) {
7+
return fgetc(stdin);
8+
}

libsrc/stdio/putchar.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#include "stdio.h"
22

3-
#if defined(__GNUC__)
43
#include "./_file.h"
54
// gcc replaces `printf("%c", c)` into `putchar(c)` implicitly.
65
#undef putchar
6+
77
// Result: Success => c, Failure => EOF
88
int putchar(int c) {
99
return _fputc(c, stdout);
1010
}
11-
#endif

0 commit comments

Comments
 (0)