ok I wrote something, but it still doesn't work
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_LINE 1024
#define MAX_CHARACTER 128
int main(void) {
int i, j, lineCount, distinct;
char input[MAX_LINE][MAX_CHARACTER];
char duplicate[MAX_LINE][MAX_CHARACTER];
i = 0;
lineCount = 0;
while ((fgets(input[i], MAX_CHARACTER, stdin)) != NULL) {
strncpy(duplicate[i], input[i], MAX_LINE);
lineCount = lineCount + 1;
i = i + 1;
}
i = 1;
distinct = 0;
while (i < lineCount) {
j = 0;
while (j < i) {
if (strcmp(input[i], duplicate[j]) != 0) {
// distinct = distinct + 1;
j = j + 1;
} else {
break;
}
}
i = i + 1;
}
// printf("%d distinct lines seen after %d lines read.\n", distinct, lineCount);
return 0;
}
so now I'm comparing it to all the previous lines, but I don't know how to skip over strings in input that already appeared before.