#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char **argv) {
    char *path;
    int fd;
    int i;
    ssize_t bytes_read;
    size_t count = 32;
    char buf[32];

    if (argc < 2) {
        fprintf(stderr, "USAGE: %s file\n", argv[0]);
        exit(EXIT_FAILURE);
    }

    path = argv[1];

    fd = open(path, O_RDONLY);
    if (-1 == fd) {
        perror("open");
        exit(EXIT_FAILURE);
    }

    if (-1 == (bytes_read = read(fd, buf, count))) {
        perror("read");
        exit(EXIT_FAILURE);
    }

    for (i = 0; i < bytes_read; ++i) {
        printf("%c", buf[i]);
    }

    if (-1 == close(fd)) {
        perror("close");
        exit(EXIT_FAILURE);
    }

    return EXIT_SUCCESS;
}
