Skip to content

Instantly share code, notes, and snippets.

@CatTail
Last active August 29, 2015 14:07
Show Gist options
  • Save CatTail/f14c438e3f476b6affc5 to your computer and use it in GitHub Desktop.
Save CatTail/f14c438e3f476b6affc5 to your computer and use it in GitHub Desktop.
block reading
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/uio.h>
int main(void)
{
char buf[80];
// read
ssize_t size = read(fileno(stdin), buf, sizeof(buf));
if (size == -1) {
perror("read()");
exit(EXIT_FAILURE);
}
printf("%s", buf);
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment