#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <wait.h>
#include <fcntl.h>

int main(int argc, char **argv){
	if (argc != 3){
		printf("Usage : %s <FILE1> <FILE2> | This program compares two files and is able to detect if they are different or same\n", argv[0]);
		return EXIT_FAILURE;
	}
	pid_t p;
	int fd1, fd2;
	char buf1, buf2;
	fd1 = open(argv[1], O_RDONLY);
	fd2 = open(argv[2], O_RDONLY);
	if (fd1 == -1 || fd2 == -1){
		perror("Error while opening files");
		return EXIT_FAILURE;
	}
	p = fork();
	switch(p){
		case -1:
			perror("Error while creating a new process");
			return EXIT_FAILURE;
		case 0:
			// Read file a
			read(fd1, &buf1, sizeof(char));
		default:
			//Read file b & compare both files
			read(fd2, &buf2, sizeof(char));