Works the same as the linux base64 -w0 command. The -w0 option means that no newlines are printed (some base64 implementations don't have this option).
$ echo $(echo "IOCCC" | ./prog)
SU9DQ0MK
Compile with cc --include stdio.h -Wno-implicit-int prog.c -o prog.
Included shorter version in "prog.short.c", which uses the fact that the EOF constant is commonly -1. The standard says that it should be a negative integer, not especially -1.
Also included a more-liner version that gives less compiler warnings (except -Wcomma from CLANG -Weverything).