All pastes #2049202 Raw Edit

Mine

public text v1 · immutable
#2049202 ·published 2011-04-22 03:22 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;
	
	while ((rc = fscanf(input, "%31s", word)) != EOF)
		{
		if (rc)
			{
			struct tnode *root;
	
		
		root = NULL;
		//printf ("%s\n", word);

			if (isalpha(word[0]))
				root = addtree(root, word);
		treeprint(root);
		Result = treeprint(root);
			
			}
		}
	
	printf("%i", Result);

	return 0;
	}




/* treeprint: in-order print of tree p */
int treeprint(struct tnode *p)
	{
            static int uniqueCount = 0;
		if (p != NULL) 
			{
				treeprint(p->left);
				printf("%4d %s\n", p->count, p->word);
				treeprint(p->right);
			}
            uniqueCount++;
            return uniqueCount;
	}