I need some assist here , my C++ code is not working

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 .



#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <fstream>
#include <cstring>
#include <cstdio>
#include <fstream>
using namespace std;



int i = 0;

ifstream inptr("member.txt");

struct Date
{
char year[5], month[3], day[3];
};

struct node
{
node *left;
node *right;
char ID[6];
char PhoneNo[11];
char Name[20];
char address[30];
struct Date DOB;
struct Date DOJ;
char group[5];
char StaffID[6];
char status[11];
};

typedef node *Tree;

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

node getfile()
{
node x;
inptr.getline(x.ID, 6, '|');
inptr.getline(x.PhoneNo, 11, '|');
inptr.getline(x.Name, 20, '|');
inptr.getline(x.address, 30, '|');
inptr.getline(x.DOB.day, 2, '|');
inptr.getline(x.DOB.month, 2, '|');
inptr.getline(x.DOB.year, 4, '|');
inptr.getline(x.DOJ.day, 2, '|');
inptr.getline(x.DOJ.month, 2, '|');
inptr.getline(x.DOJ.year, 4, '|');
inptr.getline(x.group, 5, '|');
inptr.getline(x.StaffID, 6, '|');

inptr.getline(x.status, 11, '\n');
x.left = x.right = NULL;
return x;
}

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

delete temp;
return child;
}
}
return T;
}

void display_inorder(Tree T)
{
if (T != NULL)
{
display_inorder(T->left);
cout << " "<< left << "ID: " << T->ID
<< "Phone No : " << T->PhoneNo << setw(20)
<< "Name : " << T->Name << setw(20)
<< "Address : " << T->address << setw(20)
<< "DOB : " << T->DOB.day << T->DOB.month << T->DOB.year << setw(20)
<< "DOJ : " << T->DOJ.day << T->DOJ.month << T->DOJ.year << setw(20)
<< "Group :" << T->group << setw(20)
<< "Added by : " << T->StaffID << setw(20)
<< "Status :" << T->status << setw(20) << endl;
display_inorder(T->right);
}
}

void MemberMenu(Tree T)
{
node n;
Tree N, temp;
int sel = 0;



while (sel != 4)
{

cout << "Member Menu : " << endl;
cout << "\nPlease Select your option : " << endl;
cout << "1. New Member " << endl;
cout << "2. Search " << endl;
cout << "3. Display " << endl;
cout << "4. Exit" << endl;
cin >> sel;


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;

MemberMenu(T);



inptr.close();


system("pause");

}
Hi,
> I spent a whole day on checking the mistakes
Can you give us a hint about why this is not working?
I cannot display anything out , I spent a whole day on checking the mistakes

Did you spend a whole day not checking if your file actually opened?
M0001|0165126287|LiewAhChen|22PlatinumCondo|22 5 1997|5 5 2015|VIP|S0001|Active|
M0002|0161248371|TanSiewMun|1GemilangCondo|2 1 1995|30 9 2013|VIP|S0001|NotActive|
M0003|0167551277|ChinJiaHao|54JalanAhmad|8 11 1996|28 1 2014|VIP|S0001|NotActive|
M0004|0112689974|LauMinYee|19GemilangCondo|12 1 1997|26 7 2015|VIP|S0001|Active|
M0005|0111360653|ChengZhiJun|43PlatinumCondo|11 1 1997|14 2 2015|VIP|S0001|Active|


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 ?
I found out what's the problem already , thanks guys
Topic archived. No new replies allowed.