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

int main(int argc, char* argv[]) {
    if (argc != 3) {
        fprintf(stderr, "Usage: simple-compare FILE1 FILE2\n");
        exit(EXIT_FAILURE);
    }
    FILE* f1 = fopen(argv[1], "r");
    if (f1 == NULL) {
        fprintf(stderr, "simple-compare: Couldn't open '%s'\n", argv[1]);
        exit(EXIT_FAILURE);
    }
    FILE* f2 = fopen(argv[2], "r");
    if (f2 == NULL) {
        fprintf(stderr, "simple-compare: Couldn't open '%s'\n", argv[2]);
        exit(EXIT_FAILURE);
    }
    int c1, c2;
    int n = 0;
    while ((c1 = getc(f1)) != EOF) {
        c2 = getc(f2);
        if (c1 != c2) {
            printf("Different at char number %d.\n", n);
            return EXIT_SUCCESS;
        }
        ++n;
    }
    if (getc(f2) != EOF) {
        fprintf(stderr, "simple-compare: Not the same length\n");
        exit(EXIT_FAILURE);
    }
    printf("Same.\n");            

    return EXIT_SUCCESS;
}
