/* addtree: add a node with w, at or below p */
struct tnode *addtree(struct tnode *p, char *w)
{
int i=0;
char *c;
while (w)
{
c=w[i];
putchar (tolower(c));
i++;
}
int cond;
if (p == NULL)
{ /* a new word has arrived */
p = talloc(); /* make a new node */
p->word = strdup(c);
p->count = 1;
p->left = p->right = NULL;
}
else if ((cond = strcmp(c, p->word)) == 0)
p->count++; /* repeated word */
else if (cond < 0) /* less than into left subtree */
p->left = addtree(p->left, c);
else /* greater than into right subtree */
p->right = addtree(p->right, c);
return p;
}
gcc -Wall -c -g -std=c99 wordCount.c
wordCount.c: In function 'addtree':
wordCount.c:19: warning: assignment makes pointer from integer without a cast
wordCount.c:20: warning: passing argument 1 of 'tolower' makes integer from pointer without a cast
gcc -g -std=c99 -lm main.o wordCount.o -o PA5