All pastes #2049224 Raw Edit

Unnamed

public text v1 · immutable
#2049224 ·published 2011-04-22 04:33 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;
	FILE* output;
	

	if (argc > 1)
		{
		struct tnode *root = NULL;
			for(int i = 2; i<=argc; i++)	  
			{
				//printf("File:%
			
				input = fopen(argv[i], "r");
				char word[MAXWORD] = "";
				int rc;
				
				while ((rc = fscanf(input, "%31s", word)) != EOF)
				{
				if (rc)
					{	
						if (isalpha(word[0]))
							root = addtree(root, word);
								
			
					}
				}
			}
	int Result= treeprint(root);
	printf("The Number of Unique Words is: %i\n", Result);

			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;
		}
	

	

	return 0;
	}