All pastes #2049213 Raw Edit

Unnamed

public text v1 · immutable
#2049213 ·published 2011-04-22 03:50 UTC
rendered paste body
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "wordCount.h"


#define MAXWORD 100



int main(int argc, char **argv) 
	{
	FILE* input;
	int Result;

	if (argc > 1)
		{
		input = fopen(argv[1], "r");

		if (!input)
			{
			fprintf(stderr, "Unable to open input file \"%s\". Exiting.\n", argv[1]);
			return -1;
			}
		}
	else
		{
		fprintf(stderr, "No input file specified on command line.\n");
		return -1;
		}
	

	char word[MAXWORD] = "";
	int rc;
	struct tnode *root = NULL;
	while ((rc = fscanf(input, "%31s", word)) != EOF)
		{
		if (rc)
			{
		
		//printf ("%s\n", word);

			if (isalpha(word[0]))
				root = addtree(root, word);
		
		
			
			}
		}
	Result = treeprint(root);
	printf("The Number of Unique Words is: %i\n", Result);

	return 0;
	}




-bash-3.2$ ./PA5 test.txt
   1 eight
   1 five
   2 four
   2 nine
   1 one
   2 seven
   3 six
   1 ten
   1 three
   1 two
The Number of Unique Words is: 21