Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 18th, 2003, 01:26 AM
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
  #2 (permalink)  
Old October 30th, 2003, 08:02 PM
Registered User
 
Join Date: Aug 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There are quite a few problems here - the biggest being that you just don't seem to have a real understanding of the C++ language itself(much less programming in general). I don't say that to be mean - just being realistic. What I mean is, here you are, trying to code a database, when you should be working on more pressing problems(mastering the basics, specifically). So here is my suggestion: using whatever books you have, go through every single exercise until your understanding is *completely* thorough. Then you will be able to solve problems such as these without much effort. Step-by-step is the key phrase here. Good luck.

- Sebastian Garth

"The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." - Donald Knuth
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Massive web community xtremetom Flash (all versions) 0 April 12th, 2005 12:27 PM
Massive web community xtremetom Dreamweaver (all versions) 0 April 12th, 2005 12:26 PM
massive programmed C++ Programming 0 October 18th, 2003 01:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.