So, this is my coding, but when i insert data, i cannot update view / print input that i had inserted.

And also, i had connect the database with NOTEPAD, but it does not appear. So, what is the problem?

# include <iostream.h>
# include <fstream.h>
# include <iomanip.h>

struct patient{
    int iPatientId;
    string sPatientName;
    string sPatientAddress;
    long int lPatientPhoneNo;
    string sPatientDOB;
    string sPatientBloodType;
    patient *next;
};


patient *headptr; //global variable
int iPatientId;
string sPatientName;
string sPatientAddress;
long lPatientPhoneNo;
string sPatientDOB;
string sPatientBloodType;


void menu();
void insert();
void update();
void search();
void display();
void remove();  
void insertFile();



patient *head=NULL;
patient *curr,*prev, *newptr;


fstream pasca;


void main()
{  
  headptr = NULL;
  menu();

  }



void menu(){ 

   int iInput;

   do
   {     
         cout<<"\n-- Welcome to ABC clinic. Please select your choice. --\n";
         cout<<"1) Adding a new patient record\n";
         cout<<"2) Updating the existing patient record\n";
         cout<<"3) Search a patient record\n";
         cout<<"4) View a patient record\n";
         cout<<"5) Remove a patient record\n";
         cout<<"6) Exit\n\n";
         cout<<"Please enter your choice (1/2/3/4/5/6) : ";
         cin>>iInput;   



   switch(iInput){

        case 1 : cout<<"\nYour choice: `Adding a new patient record'\n\n";
                 insert();
                 menu();
                 break;

        case 2 : cout<<"\n\nYou choice: `Updating the existing patient record'\n\n";
                 update();
                 menu();
                 break;

       case 3 : cout<<"\n\nYour choice: `Search a patient record'\n\n";
                search();
                menu();
                break;


       case 4 :  cout<<"\n\nYour choice: `View a patient record'\n\n";
                 display();
                 //sorted();
                 menu();
                 break;

       case 5 :  cout<<"\n\nYour choice: `Remove a patient record'\n\n";
                 remove();
                 menu();
                 break;

       case 6 :  cout<<"\n\nYour choice: `Exit'\n";
                cout<<"Goodbye ...\n";
                exit(0);
                break;

                }

   }while(iInput!=6);

}



void insert()
   {  

      /*declare newptr sebagai pointer baru*/
      patient *newptr; 
      newptr = new patient;
      //system("CLS");


    cout<<"Insert new data"<<endl<<endl;
    cout<<" Please enter patient Id : "<<endl;
    cin>>newptr->iPatientId;
    cout<<"Please enter patient name : "<<endl;
    //cin.getline(newptr->sPatientName);
    cin>>newptr->sPatientName;
    cout<<"Please enter patient address : "<<endl;
    //cin.getline(newptr-> sPatientAddress);
    cin>>newptr->sPatientAddress;

    cout<<"Please enter patient phone number : "<<endl;
    cin>>newptr->lPatientPhoneNo;
    cout<<"Please enter patient date of birth : "<<endl;
    cin>>newptr->sPatientDOB;
    cout<<"Please enter patient blood type : "<<endl;
    cin>>newptr-> sPatientBloodType;

    cout<<"Enter your choice :";
    menu();

      //newptr->next = NULL;
      //newptr->Date=NULL;
      cout<<"\n\t         SUCCESFULLY REGISTERED \n\n";



      if (head == NULL)
      {
         head = newptr ;
      }
      else
      {
         newptr->next=head;
         head=newptr;
      }

   }



void update()
{

   int iChoice;
   search();



   do
   {  
      //system("CLS");      
      cout<<"\n\t*                         1. ID                                    *";
      cout<<"\n\t*                         2. Name                                  *";
      cout<<"\n\t*                         3. Address                               *";
      cout<<"\n\t*                         4. Phone Number                          *";
      cout<<"\n\t*                         5. Date of Dirth                         *";
      cout<<"\n\t*                         6. Blood Type                            *";
      cout<<"\n\t*                         7. Cancel                                *";
      cin>>iChoice;



      if (iChoice==1)
     {
         //cin.ignore()
         cout<<"\n\t                 Enter the new ID  :";
         cin>>curr->iPatientId;
         cout<<"\n\t                 Successful Update!!!\n";  
      }

      else if(iChoice==2)
      {
         cout<<"\n\t                 Enter the new name :";
         cin>>curr->sPatientName;  
         cout<<"\n\t                 Successful Update!!!\n";  
      }

      else if(iChoice==3)
      {  
         cin.ignore();
         cout<<"\n\t                 Enter the new address  :";
         //cin.getline(curr->sPatientAddress,60);
         cin>>newptr->sPatientAddress;
         cout<<"\n\t                 Successful Update!!!\n";  
      }

      else if(iChoice==4)
      {
         cout<<"\n\t                 Enter the new phone number  :";
         cin>>curr->lPatientPhoneNo;
         cout<<"\n\t                 Successful Update!!!\n";     
      }

      else if(iChoice==5)
      {
         cout<<"\n\t                 Enter the new Date of Birth  :";
         cin>>curr->sPatientDOB;
         cout<<"\n\t                 Successful Update!!!\n";     
      }

      else if(iChoice==6)
      {
         cout<<"\n\t                 Enter the new blood type :";
         cin>>curr->sPatientBloodType;
         cout<<"\n\t                 Successful Update!!!\n";     
      }

      else if(iChoice==7)
      {
      }

      else
      {
         cout<<"\n\t                 You are entering the wrong input \n";
      }
      system("pause");
     }
      while(iChoice!=7);

}




void search()
{
   //system("CLS");

   curr=head;

   if(head == NULL)
      {
        cout<<"\n\n";
      }
   else
      {
        while(curr!=NULL)                                       
          {
            cout<<"\n\n        \t"<<curr->iPatientId<<            "\t "<<curr->sPatientName<<"\         \t"<<curr->sPatientAddress<<endl;           
            curr = curr->next;                                    
         }
       }


   /*masukkan nombor id yang ingin dicari*/

   cout<<"\n\n\t                 Enter patient ID : ";
   cin>>iPatientId;
   /*set prev NULL and cur to head*/

   prev=NULL;
   curr=head;

   while(curr!=NULL && iPatientId!=curr->iPatientId) 
   {
      prev=curr;
      curr=curr->next;

   }

   if(curr==NULL)
   {
      cout<<"\n\t                Sorry, the data not found!\n\n\n";
   }


   else
   {
      cout<<"\n\t                 Data Founded !!!!!!";
      cout<<"\n\n\n\t             ID      : "<<curr->iPatientId<<endl;
      cout<<"\n\t                 Name        : "<<curr->sPatientName<<endl;
      cout<<"\n\t                 Address    : "<<curr->sPatientAddress<<endl;
      //cout<<"\n\t                 Phone Number    : "<<curr->lPatientPhoneNo<<endl;
      cout<<"\n\t                 Date of Birth    : "<<curr->sPatientDOB<<endl;
      cout<<"\n\t                 Blood Type  : "<<curr->sPatientBloodType<<"\n\n\n";
      }
     system("pause");
}



void display()
{  

   //system("CLS");
   cout<<"\n\n\t                 Enter patient ID  : ";
   cin>>iPatientId;
   prev=NULL;
   curr=head;
   while(curr!=NULL && iPatientId!=curr->iPatientId) 
   {
     prev=curr;
      curr=curr->next;

   }

   if(curr==NULL)
   {
      cout<<"\n\t                 Sorry, the data not found !!!!!!!!!";
   }

  else
   {
      //system("CLS");
      cout<<"_______________________________________________________________________________";
      cout << "\nID" << "\tName" << "\tAddress" << "\tPhone Number" << "\tDate of Birth" << "\tBlood Type" << endl;
      cout<<curr->iPatientId<<"\t\t"<<curr->sPatientName<<"\t\t"<<curr->sPatientAddress<<"\t\t"<<curr->lPatientPhoneNo<<"\t\t"<<curr->sPatientDOB<<"\t\t"<<curr->sPatientBloodType;
      curr=curr->next;
      cout<<"______________________________________________________________________________"<<endl;   
}
system("pause");

}



void remove(){

    int iNumber;
    cout<<"Please enter the number to be deleted: \n\n";
    cin>>iNumber;

    if(headptr == NULL)
        cout<<"Sorry the list is empty. \n\n";

    else{

        patient *prevptr, *curptr;

        curptr = headptr;
        prevptr = NULL;

        while((curptr != NULL) && (iNumber != curptr->iPatientId)) {
            prevptr = curptr;
            curptr = curptr->next;
        }

        if(curptr == NULL){
            cout<<"\nSorry, data is not found.\n\n";
        }

        else if (prevptr == NULL) {
            headptr = headptr->next;
            delete curptr;
        }

        else {
            prevptr->next = curptr->next;
            delete curptr;
        }
    } 
} 
/*void remove()
{  
   /* panggil fungsi cari()
   char answer;
   search();
   if (curr==NULL)
   {
   cout<<"\n\t                 Sorry, the data not found !!!!!!\n\n";
   system("pause");
   }
   else
   {
      patient *p;
      system("CLS");
      cout<<"\n\n\t********************************************************************";
      cout<<"\n\t*                           Delete the data                           *";
      cout<<"\n\t**********************************************************************";
      cout<<"\n\n\tAre you sure want to delete the data? "<<curr->sPatientName<<" DATA ? (Y=yes || N =NO )"<<endl;
      cin>>answer;
      if(answer=='y' || answer=='Y')
      {     
         p=curr;

         if(prev==NULL)
         {
            head=head->next;
            delete p;
            cur1 = curr->Date;
            /* looping until p->Date not to NULL
            * b for Date pointer want to delete

            while (p->Date!=NULL)                                           
            {  patient *b;
               b=p->Date;                                                
               cur->Date=cur->Date->next1;                                           
               delete b;
            }

            cout<<"\n\t                 Data successful deleted!!!!!!!!"<<endl;       
         }

         else
         {
            prev->next = p->next;
            cur1 = p->Date;
         while (p->Date!=NULL)                                          
            {  T_lawat *b;    
               b=p->Date;                                               
               cur->Date=cur->Date->next1;                                       
               delete b;
            }
            delete p;
            cout<<"\n\t                 Data successful deleted!!!!!!!!!"<<endl;
         }                                               // buang curr
      }
      else
      {
         cout<<"\n\n\t                 Cancel deletion\n\n";
         system("pause");
      }
   }
} */



void insertFile()
{
   fstream pasca;
   pasca.open("patientRecord.txt",ios::app);

   curr = head;

   while(curr!=NULL)
   {

   pasca<<"\nID     : "<<curr->iPatientId<<endl;
   pasca<<"\nName   : "<<curr->sPatientName<<endl;
   pasca<<"\nAddress : "<<curr->sPatientAddress<<endl;
   //pasca<<"\nPhone Number: "<<curr->lPatientPhoneNo<<endl;
   pasca<<"\nDate of Birth : "<<curr->sPatientDOB<<endl;
   pasca<<"\nBlood Type : "<<curr->sPatientBloodType<<endl;

   curr = curr->next;
   }
   exit(1);

}


/************************************
* End of patientRecord.cpp
************************************/

Your code never inserts a patient record.

Your insert function never gets to line 146 because on line 138 you call menu().

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.