#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
#define BUFSIZE 512

int main(int argc, char * argv[]) {
    char cTemp;
    FILE * src, * dest;
    if (argc!=3) {
        printf ("Usage: flength source destination\n");
        return (-1); }

    src = fopen(argv[1], "rb"); 
    if (!src) {
        printf ("Source File could not be opened! Aborting...");
        return (-2); }
        
    dest = fopen(argv[2], "wb");  
    if (!src) {
        printf ("Destination file could not be opened! Aborting...");
        return (-3); }

    while(fread(&cTemp, 1, 1, src) == 1) {
    fwrite(&cTemp, 1, 1, dest); }

    fclose(src);
    fclose(dest);
    return (0); }
