
/* 
(c) 1995 by Dan Goldwater.  12/16/95

takes two wordlists and lists any words in the second which
are not in the first.

both input lists must be sorted alphabetically.
the output list will retain alphabetical order.
*/

#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>


int main(int argc, char *argv[])
{
	int i;
	char str1[40];				// input word
	char str2[40];				// input word
	FILE *word_file_1;			// the input data file
	FILE *word_file_2;			// the input data file
	FILE *word_out_file;		// the output data file

	/* open input file in read-only mode */
	if((word_file_1 = fopen(argv[1], "r")) == NULL)
	{
		printf("you must specify two data files\n");
		return 1;
	}
	if((word_file_2 = fopen(argv[2], "r")) == NULL)
	{
		printf("you must specify two data files\n");
		return 1;
	}

	_strset(str1, 0);
	_strset(str2, 0);
	fscanf(word_file_1, "%s", str1);
	fscanf(word_file_2, "%s", str2);
	while((!feof(word_file_1)) && (!feof(word_file_2)))
	{
		// printf("%s %s\n", str1, str2);  // for debugging
		i = _stricmp(str1, str2);
		if(i<0)		/* word1 is first alphabetically, get next word1 */
		{
			fscanf(word_file_1, "%s", str1);
		}
		if(i==0)	/* i=0 both words are the same, so go to next word */
		{
			fscanf(word_file_1, "%s", str1);
			fscanf(word_file_2, "%s", str2);
		}
		if(i>0)		/* word2 is first alphabetically, so no match found */
		{
			printf("%s\n", str2);
			fscanf(word_file_2, "%s", str2);
		}
	}

	if(feof(word_file_1))  /* all remaining words in file2 are not in file 1 */
	{
		while(!feof(word_file_2))
		{
			printf("%s\n", str2);
			fscanf(word_file_2, "%s", str2);
		}
	}

	fclose(word_file_1);
	fclose(word_file_2);
	return 0;
}
