All pastes #2049235 Raw Edit

Unnamed

public text v1 · immutable
#2049235 ·published 2011-04-22 05:27 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;	
	

	if (argc > 1)
		{
		struct tnode *root = NULL;
			for(int i = 1; i<argc; i++)	  
			{
				printf("File:%s\n", argv[i]);
			
				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);
								
			
					}
				}
			fclose(input);
			}
			
	int Result= treeprint(root);
	printf("The Number of Unique Words is: %i\n", Result);
	treeFree(root);
	//printf("0x%X\n", (unsigned int)root);
	printf ("pointer value: 0x%X pointer address: 0x%X\n", (unsigned int)root, (unsigned int)&root);

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