Skip to content

Instantly share code, notes, and snippets.

@stepancheg
Created November 2, 2013 20:19
Show Gist options
  • Save stepancheg/7283047 to your computer and use it in GitHub Desktop.
Save stepancheg/7283047 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
int main() {
for (;;) {
char buf[1];
ssize_t r = read(STDIN_FILENO, buf, 1);
if (r == 0) {
break;
} else if (r < 0) {
perror("read");
exit(1);
} else {
printf("%d\n", (int) buf[0]);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment