Thread: massive
View Single Post
  #1 (permalink)  
Old October 18th, 2003, 01:26 AM
programmed programmed is offline
Authorized User
 
Join Date: Oct 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default massive

 Hullo wrox,
 i seek you guidance on this coding, i'm creating a dbase in C++/C, after i write some data, the user is given options to choose from.'
Say,Find(to find a record in the Dbase) but it still compiles with 2 errors.
My techique in the coding is that, i pass on the address of the entire class to function.
In the function defn., i open the file for reading, prompt for someone to enter the account number(my primary key) then search through the entire class, if found display the number, else error msg.
Below is a sample of the code;

class bal
 {
   int acc;
 public:
       double balance;
       char name[1];
      // friend changeit(bal *t); //to access private members of the class
 }person[100];

Then the function defintion;
void changeit(bal *t)
 {

  // p=&person;
  cout<<"Enter the Account Number to be found"<<endl;
    int num;
   if((fp=fopen("temp.txt","r+"))==NULL);
     {
      cerr<<"Cannot open File."<<endl;
      cout<<"Press any Key...";
      getch();
      exit(1);
    }
   if((fp=fopen("temp.txt","r+"))!=0)
     {
       for(int i=0;i<tin;++i)
    {
     fread((char*)&person,sizeof(bal),1,fp);
      t->acc;
       // int *div;
// strcpy(div,p);
       int x;
        if(acc==num)
          {
        cout<<endl<<"Your Account number is!"<<t;
          }
       else
         {
           cout<<endl<<"Account number not found.";
         }
     }
     }
  getche();
}
The calling function;
 cprintf("CLOSE | ADD | FIND | DELETE");
     gotoxy(2,24);
       cprintf("Type your option here...");
        char choice[10];
          cin>>choice;
        if(strcmp(choice,"FIND")==0)
          {
    //function call changeit(&person);
                  }


Thanks in advance.

Antonio.

Reply With Quote