My code is as below , I cannot display anything out , I spent a whole day on checking the mistakes , but I can't found any . I'm looking for some help here , thanks a lot if you could help me .
Tree InitializeTree();
Tree InsertTree(Tree x, Tree T);
Tree getnode(node newmember);
node getfile();
Tree TextfileToTree(Tree T);
Tree FindNode(char id[6], Tree T);
Tree FindMin(char id[6], Tree T);
Tree deleteTree(char id[6], Tree T);
void display_inorder(Tree T);
void MemberMenu(Tree T);
void main();
Tree InitializeTree()
{
return NULL;
}
Tree InsertTree(Tree x, Tree T)
{
if (T == NULL)
T = x;
else if (strcmp(T->ID, x->ID)<0)
{
T->right = InsertTree(x, T->right);
}
else if (strcmp(T->ID, x->ID)>0)
{
T->left = InsertTree(x, T->left);
}
return T;
}
Tree getnode(node newmember)
{
node* newnode = new node;
*newnode = newmember;
newmember.left = newmember.right = NULL;
return newnode;
}
Tree TextfileToTree(Tree T)
{
while (!inptr.eof())
{
T = InsertTree(getnode(getfile()), T);
}
return T;
}
Tree FindNode(char id[6], Tree T)
{
if (T == NULL)
return NULL;
else if (strcmp(id, T->ID)<0)
return FindNode(id, T->left);
else if (strcmp(id, T->ID)>0)
return FindNode(id, T->right);
else
return T;
}
Tree FindMin(char id[6], Tree T)
{
if (T == NULL)
return NULL;
else if (T->left == NULL)
return T;
else
return FindMin(id, T->left);
}
Tree deleteTree(char id[6], Tree T)
{
Tree temp, child = 0;
if (T == NULL)
cout << "Error : Item not found . " << endl;
else if (strcmp(id, T->ID)<0)
T->left = deleteTree(id, T->left);
else if (strcmp(id, T->ID)>0)
T->right = deleteTree(id, T->right);
else //Find item to delete
{
if (T->left && T->right) //if the node has two children
{
temp = FindMin(id, T->right); //replace with the smallest in right
id = temp->ID;
T->right = deleteTree(T->ID, T->right);
}
else
{
temp = T;
if (T->left == NULL) //only for a right child
child = T->right; //reattach the right child
if (T->right == NULL) //only a left child
child = T->left; //reattach the left child
switch (sel)
{
case 1:
cout << "New Member ID : " << endl;
cin.ignore();
cin.getline(n.ID, 6);
cout << "New Member's Phone Number : " << endl;
fflush(stdin);
cin.getline(n.PhoneNo, 11);
cout << "New Member Name : " << endl;
fflush(stdin);
cin.getline(n.Name, 20);
cout << "New Member's Address : " << endl;
fflush(stdin);
cin.getline(n.address, 30);
cout << "New Member's Date of Birth : " << endl;
fflush(stdin);
cin.getline(n.DOB.day, 2);
fflush(stdin);
cin.getline(n.DOB.month, 2);
fflush(stdin);
cin.getline(n.DOB.year, 4);
cout << "New Member's Date of Join : " << endl;
fflush(stdin);
cin.getline(n.DOJ.day, 2);
fflush(stdin);
cin.getline(n.DOJ.month, 2);
fflush(stdin);
cin.getline(n.DOJ.year, 4);
cout << "New Member's Group(VIP/NOR) : " << endl;
fflush(stdin);
cin.getline(n.group, 5);
cout << "Added by(Staff ID) : " << endl;
fflush(stdin);
cin.getline(n.StaffID, 6);
cout << "New Member's Status : " << endl;
fflush(stdin);
cin.getline(n.status, 11);
n.left = n.right = NULL;
N = getnode(n);
T = InsertTree(N, T);
break;
case 2:
cout << "Enter the Member ID that you want to search: " << endl;
cin >> n.ID;
temp = FindNode(n.ID, T);
cout << "Member ID : " << n.ID << endl;
cout << "Name : " << n.Name << endl;
cout << "Address : " << n.address << endl;
cout << "Phone No : " << n.PhoneNo << endl;
cout << "Date of Birth : " << n.DOB.day << n.DOB.month << n.DOB.year << endl;
cout << "Date of Join : " << n.DOJ.day << n.DOJ.month << n.DOJ.year << endl;
cout << "Group : " << n.group << endl;
cout << "Added By : " << n.StaffID << endl;
cout << "Status : " << n.status << endl;
break;
case 3:
cout << "Current Member list :" << endl;
display_inorder(T);
break;
}
}
}
void main()
{
char id[6];
inptr.open("member.txt");
Tree F, T;
T = InitializeTree();
T = TextfileToTree(T);
cout << "WELCOME TO XXX FITNESS CENTRE MANAGEMENT SYSTEM" << endl;
oh sorry, this is the content of my member.txt
or I should say it does work , but it doesn't display anything , it is because it doesn't open the file ?