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

int main(int argc, char **argv){
	if (argc < 3){
		printf("Syntax: executable source target.\n");
		return 0;
	}
	FILE *source = fopen(argv[1], "r");
	if (source == NULL){
		printf("Cannot open file %s!\n",argv[1]);
		return 0;
	}

	fseek(source,0,SEEK_END);
	long size = ftell(source);
	fseek(source,0,SEEK_SET);

	void *filecontent;
	filecontent = malloc(size);
	if (filecontent == NULL){
		printf("Error while allocating memory!\n");
		return 0;
	}

	fread(filecontent,size,1,source);

	fclose(source);

	FILE *target = fopen(argv[2],"w");

	fwrite(filecontent,size,1,target);

	fclose(target);

	free(filecontent);

	printf("Operation completed!\n");

	return 0;
}



