Untitled

 avatar
unknown
plain_text
4 years ago
480 B
5
Indexable
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

int main(int arg, char* argv[]) {
    size_t bytes_written;

    for (int offset = 0; offset < strlen(argv[1]); offset += bytes_written) {
        bytes_written = write(STDOUT_FILENO, argv[1] + offset, strlen(argv[1]) - offset);

        if (bytes_written == -1) {
            perror("failed to write");
            return errno;
        }
    }

    return 0;
}
Editor is loading...