title: c++, Display the records in data base which are having same date
body: <p>I need to display the records which are having specific date. Please check "void display_fromDate". I'm receiving error "expected primary expression before char" and pointing the "int main() --> case 2. Appreciate your advise.</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;fstream&gt;
  #include&lt;iomanip&gt;
  
  using namespace std;
  
  
  
  class patient
  {
      int contactnum;
      char name[50];
      //float add;
      char bookingDate[15];
      char bookingTime[5];
      char trtType[15];
      //int add, bookingDate, bookingTime;
      //double per;
      //char grade;
      //void calculate(); 
  public:
      void getdata();     
      void showdata() const;  
      void show_tabular() const;
      int getIDNum() const;
      char bDate() const;
  }; 
  
  
  /*void patient::calculate()
  {
      per=(physics+chemistry+mathematics+english+comscience)/5.0;
      if(per&gt;=90)
          grade='A+';
      else if(per&gt;=80)
          grade='A';
      else if(per&gt;=75)
          grade='A-';
      else if(per&gt;=70)
          grade='B+';
      else if(per&gt;=65)
          grade='B';
      else if(per&gt;=60)
          grade='B-';
      else if(per&gt;=55)
          grade='C+';
      else if(per&gt;=50)
          grade='C';
      else
          grade='F';
  }*/
  
  void patient::getdata()
  {
      cout&lt;&lt;"\nEnter The Contact Number of the Patient ";
      cin&gt;&gt;contactnum;
      cout&lt;&lt;"\n\nEnter Patient's Name: ";
      cin.ignore();
      cin.getline(name,50);   
      cout&lt;&lt;"\nEnter Booking Date: ";
      cin&gt;&gt;bookingDate;
      cout&lt;&lt;"\nEnter Booking Time: ";
      cin.ignore();
      cin&gt;&gt;bookingTime;
      cout&lt;&lt;"\nEnter Treatment Type: ";
      cin&gt;&gt;trtType;
      //calculate();
  }
  
  void patient::showdata() const
  {
      cout&lt;&lt;"\nContact Number: "&lt;&lt;contactnum;
      cout&lt;&lt;"\nName: "&lt;&lt;name;
      cout&lt;&lt;"\nBooking Date: "&lt;&lt;bookingDate;
      cout&lt;&lt;"\nBooking Time: "&lt;&lt;bookingTime;
      cout&lt;&lt;"\nTreatment Type: "&lt;&lt;trtType;
  
  }
  
  void patient::show_tabular() const
  {
      cout&lt;&lt;contactnum&lt;&lt;setw(6)&lt;&lt;" "&lt;&lt;name&lt;&lt;setw(4)&lt;&lt;bookingDate&lt;&lt;setw(4)&lt;&lt;bookingTime&lt;&lt;setw(4)&lt;&lt;trtType&lt;&lt;endl;
  }
  
  int  patient::getIDNum() const
  {
      return contactnum;
  }
  
  
  
  void Savepatient(); 
  void displayAll();  
  void Searchdisplay(int);    
  void modifypatient(int);    
  void deletepatient(int);    
  void DisplayClassResult();  
  void DisplayResult();           
  
  
  
  
  
  void write_patient()
  {
      patient st;
      ofstream outFile;
      outFile.open("patient.dat",ios::binary|ios::app);
      st.getdata();
      outFile.write(reinterpret_cast&lt;char *&gt; (&amp;st), sizeof(patient));
      outFile.close();
      cout&lt;&lt;"\n\nPatient record has been Created ";
      cin.ignore();
      cin.get();
  }
  
  
  
  /*void display_all()
  {
      patient st;
      ifstream inFile;
      inFile.open("patient.dat",ios::binary);
      if(!inFile)
      {
          cout&lt;&lt;"File could not be open !! Press any Key...";
          cin.ignore();
          cin.get();
          return;
      }
      cout&lt;&lt;"\n\n\n\t\tDISPLAY ALL RECORD !!!\n\n";
      while(inFile.read(reinterpret_cast&lt;char *&gt; (&amp;st), sizeof(patient)))
      {
          st.showdata();
          cout&lt;&lt;"\n\n====================================\n";
      }
      inFile.close();
      cin.ignore();
      cin.get();
  }*/
  
  void display_fromDate(char n)
  {
      patient st;
      ifstream inFile;
      inFile.open("patient.dat",ios::binary);
      if(!inFile)
      {
          cout&lt;&lt;"File could not be open !! Press any Key...";
          cin.ignore();
          cin.get();
          return;
      }
      bool flag=false;
      while(inFile.read(reinterpret_cast&lt;char *&gt; (&amp;st), sizeof(patient)))
      {
          if(st.bDate()==n)
          {
               st.showdata();
               flag=true;
          }
      }
      inFile.close();
      if(flag==false)
          cout&lt;&lt;"\n\nrecord not exist...";
      cin.ignore();
      cin.get();
  }
  
  
  
  
  
  void display_sp(int n)
  {
      patient st;
      ifstream inFile;
      inFile.open("patient.dat",ios::binary);
      if(!inFile)
      {
          cout&lt;&lt;"File could not be open !! Press any Key...";
          cin.ignore();
          cin.get();
          return;
      }
      bool flag=false;
      while(inFile.read(reinterpret_cast&lt;char *&gt; (&amp;st), sizeof(patient)))
      {
          if(st.getIDNum()==n)
          {
               st.showdata();
               flag=true;
          }
      }
      inFile.close();
      if(flag==false)
          cout&lt;&lt;"\n\nrecord not exist...";
      cin.ignore();
      cin.get();
  }
  
  
  void modify_patient(int n)
  {
      bool found=false;
      patient st;
      fstream File;
      File.open("patient.dat",ios::binary|ios::in|ios::out);
      if(!File)
      {
          cout&lt;&lt;"File could not be open !! Press any Key...";
          cin.ignore();
          cin.get();
          return;
      }
          while(!File.eof() &amp;&amp; found==false)
      {
  
          File.read(reinterpret_cast&lt;char *&gt; (&amp;st), sizeof(patient));
          if(st.getIDNum()==n)
          {
              st.showdata();
              cout&lt;&lt;"\n\nPlease Enter The New Details of Patient"&lt;&lt;endl;
              st.getdata();
                  int pos=(-1)*static_cast&lt;int&gt;(sizeof(st));
                  File.seekp(pos,ios::cur);
                  File.write(reinterpret_cast&lt;char *&gt; (&amp;st), sizeof(patient));
                  cout&lt;&lt;"\n\n\t Record Updated";
                  found=true;
          }
      }
      File.close();
      if(found==false)
          cout&lt;&lt;"\n\n Record Not Found ";
      cin.ignore();
      cin.get();
  }
  
  
  
  void delete_patient(int n)
  {
      patient st;
      ifstream inFile;
      inFile.open("patient.dat",ios::binary);
      if(!inFile)
      {
          cout&lt;&lt;"File could not be open !! Press any Key...";
          cin.ignore();
          cin.get();
          return;
      }
      ofstream outFile;
      outFile.open("Temp.dat",ios::out);
      inFile.seekg(0,ios::beg);
      while(inFile.read(reinterpret_cast&lt;char *&gt; (&amp;st), sizeof(patient)))
      {
          if(st.getIDNum()!=n)
          {
              outFile.write(reinterpret_cast&lt;char *&gt; (&amp;st), sizeof(patient));
          }
      }
      outFile.close();
      inFile.close();
      remove("patient.dat");
      rename("Temp.dat","patient.dat");
      cout&lt;&lt;"\n\n\tRecord Deleted ..";
      cin.ignore();
      cin.get();
  }
  
  
  void class_result()
  {
      patient st;
      ifstream inFile;
      inFile.open("patient.dat",ios::binary);
      if(!inFile)
      {
          cout&lt;&lt;"File could not be open !! Press any Key...";
          cin.ignore();
          cin.get();
          return;
      }
      cout&lt;&lt;"\n\n\t\tALL PATIENTS BOOKING DETAILS\n\n";
      cout&lt;&lt;"==============================================================\n";
      cout&lt;&lt;"Mobile.No      Name                Booking Date   Booking Time"&lt;&lt;endl;
      cout&lt;&lt;"==============================================================\n";
      while(inFile.read(reinterpret_cast&lt;char *&gt; (&amp;st), sizeof(patient)))
      {
          st.show_tabular();
      }
      cin.ignore();
      cin.get();
      inFile.close();
  }
  
  
  
  
  int main()
  {
      char ch;
      int num;
      cout.setf(ios::fixed|ios::showpoint);
      cout&lt;&lt;setprecision(2); 
      do
      {
      system("cls");
      cout&lt;&lt;"\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
      cout&lt;&lt;"\n\n\t1.CREATE PATIENT RECORD";
      cout&lt;&lt;"\n\n\t2.DISPLAY ALL PATIENTS RECORDS";
      cout&lt;&lt;"\n\n\t3.SEARCH PATIENT RECORD ";
      cout&lt;&lt;"\n\n\t4.MODIFY PATIENT RECORD";
      cout&lt;&lt;"\n\n\t5.DELETE PATIENT RECORD";
      cout&lt;&lt;"\n\n\t6.DISPLAY CLASS RESULT";
      cout&lt;&lt;"\n\n\t7.EXIT";
      cout&lt;&lt;"\n\n\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
      cout&lt;&lt;"\n\n\tPlease Enter Your Choice (1-7): ";
      cin&gt;&gt;ch;
      system("cls");
      switch(ch)
      {
      case '1':   write_patient(); break;
      case '2':   display_fromDate(char n); break;
      case '3':   cout&lt;&lt;"\n\n\tPlease Enter Patient's Contact Number: "; cin&gt;&gt;num;
                  display_sp(num); break;
      case '4':   cout&lt;&lt;"\n\n\tPlease Enter Patient's Contact Number: "; cin&gt;&gt;num;
              modify_patient(num);break;
      case '5':   cout&lt;&lt;"\n\n\tPlease Enter Patient's Contact Number: "; cin&gt;&gt;num;
              delete_patient(num);break;
      case '6' :  class_result(); break;
      case '7':   exit(0);;
      default:    cout&lt;&lt;"\a"; 
  
      }
      }while(ch!='7');
  
      return 0;
  }
  </code></pre>