统计 各个单词的出现次数 无法输出,帮忙看看,谢!
											统计各个单词出现个数  但没有输出  ????
程序代码:#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct node node;
struct node
{
  char* p_word;
  int count;
  node* left;
  node* right;
};
int main()
{
  void print_tree(node*);
  void test(node*,char*);
  node* root=NULL;
  char* buf=malloc(sizeof(char)*20);
  char* text=malloc(sizeof(char)*300);
  setbuf(stdin,NULL);
  scanf("%s",buf);
  while(*buf!='0')   //输入0开头的行代表输入结束
    {
      strcat(text,buf);
      setbuf(stdin,NULL);
      scanf("%s",buf);
    }
  char* p=text;
  p=strtok(p," ,.?!\n");
  while(p!=NULL)
    {
      test(root,p);
      p=strtok(NULL,",.?!\n ");
    }
  node* p_node=root;
  print_tree(p_node);
}
void print_tree(node* p)
{
  if(p==NULL)
    ;
  else
    {
      print_tree(p->left);
      printf("%s:%d\n",p->p_word,p->count);
      print_tree(p->right);
    }
}
void test(node* root,char* p)
{
  if(root==NULL)
    {
      root=malloc(sizeof(node));
      root->p_word=p;
      root->count=1;
      root->left=root->right=NULL;
    }
  else if(strcmp(p,root->p_word)==0)
    root->count++;
  else if(strcmp(p,root->p_word)<0)
    test(root->left,p);
  else if(strcmp(p,root->p_word)>0)
    test(root->right,p);
   
}


											
	    

	