- 论坛徽章:
- 0
|
各位大哥,小弟初学请指教:
#include <stdio.h>;
#include <malloc.h>;
struct sbin_node
{
char data;
struct sbin_node *left;
struct sbin_node *right;
};
init_bin_node(tree)
struct sbin_node *tree;
{
char c;
printf("Input a char:\n" ;
scanf("%c",&c);
if(c == '#')
{
tree = NULL;
}
else
{
tree = (struct sbin_node *)malloc(sizeof(struct sbin_node));
if(tree == NULL)
{
printf("ERR: assign memory failure\n" ;
exit( -1);
}
tree->;data = c;
init_bin_node(tree->;left);
init_bin_node(tree->;right);
}
}
main()
{
struct sbin_node *tree;
init_bin_node(tree);
} |
|