//#!/usr/local/bin/tcc -run #include #include #include #include int main(int argc, char** argv) { if(argc != 3) { fprintf(stderr, "Usage: %s infile outfile\n", argv[0]); return 1; } int in = open(argv[1], O_RDONLY); if(in == -1) { fprintf(stderr, "%s: Could not open in-file: %s\n", argv[0], argv[1]); return 1; } int out = open(argv[2], O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); if(out == -1) { close(in); fprintf(stderr, "%s: Could not open out-file: %s\n", argv[0], argv[2]); return 1; } const size_t OUTBUFFSIZE = 10; char outbuff[OUTBUFFSIZE]; time_t inbuff; //read until end while(1) { size_t rc = read(in, &inbuff, sizeof(inbuff)); if(rc != sizeof(inbuff)) break; //prnt to file size_t count = dprintf(out, "%u\n", inbuff); if(count == 0) { fprintf(stderr, "%s: Writing failed\n", argv[0]); break; } } close(in); close(out); printf("Successfull!\n"); return 0; }