Skip to content

Instantly share code, notes, and snippets.

@zaccone
Created July 1, 2015 13:55
Show Gist options
  • Save zaccone/d227e697cd25dd979978 to your computer and use it in GitHub Desktop.
Save zaccone/d227e697cd25dd979978 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#define BUF_SIZE 128
int main() {
char *path= "/tmp/file";
char *buf[BUF_SIZE];
int fd = open(path, O_RDONLY);
int size = 0;
while((size = read(fd, buf, BUF_SIZE)) != 0) {
write(1, buf, size);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment